In an asp.net application, I need to validate user input against a configurable regular expression. I have a list of such regular expressions in a db, and it is user configurable, not fixed. My problem is that in these regexps, the dot is intented to match not any character, but any 'reasonable' character (reasonable in that context: letters, digits and some other ascii character). So the validation process is carried on in 2 steps
- Check against reg exp from list
- Check against 'reasonable' characters with something like
^[\w.+/-]*$
I'd like to use a single regexp, so that I can put it in a single regexp validator on the page - that gives a better user experience. I can do that searching the dots inside the regexp and replacing with my stricter character class [\w.+/-].
But not all the dots have the same meaning in a regexp.
So my question is : there is a tried and true way to find dots inside a regexp, but only when used as a character class? A regexp maybe?
.? How will you be able to determine which dots actually mean "some other class"? Is there a specific pattern?[,.-]may have to be treated differently is your comment, or the assumption that if a group would contain duplication with the "other" meaning it shouldn't be treated as that "other" meaning.