Generic validate input data via regex. Input error when match.count == 0

Posted by Valamas on Stack Overflow See other posts from Stack Overflow or by Valamas
Published on 2011-02-07T22:51:00Z Indexed on 2011/02/07 23:25 UTC
Read the original article Hit count: 217

Filed under:
|
|
|

Hi, I have a number of types of data fields on an input form, for example, a web page.

Some fields are like, must be an email address, must be a number, must be a number between, must have certain characters. Basically, the list is undefinable.

I wish to come up with a generic way of validating the data inputed. I thought I would use regex to validate the data. The fields which need validation would be related to a "regex expression" and a "regex error message" stating what the field should contain.

My current mock up has that when the match count is zero, that would signify an error and to display the message. While still a white belt regex designer I have come to understand that in certain situations that it is difficult to write a regex which results in a match count of zero for every case.

A complex regex case I looked for help on was Link Here. The forum post was a disaster because I confused people helping me. But one of the statements said that it was difficult to make a regex with a match count of zero meaning the input data was invalid; that the regex was very difficult to write that for.

Does anyone have comments or suggestions on this generic validation system I am trying to create?

thanks

© Stack Overflow or respective owner

Related posts about .NET

Related posts about regex