in reply to Re: Regex : Limit value of a string
in thread [SOLVED] Regex : Limit value of a string
Wholeheartedly agree. And here, to me, is why: a regex pattern should match what the string looks like, and to extract pieces from it, whereas if/then logic should then be used to test for what those pieces contain. Now, obviously, there are cases where certain digits of a string are known to serve only as identifiers of the string itself ... e.g. the leading digits of ISBNs for books ... but this is not such a case. Someday it is quite likely that someone will want to change this logic, say to allow a different number to be in this position, or to allow more than one, or to add some other ruling constraint. If you are doing this in the regex, you’re making a mess for that person. :-)