This post I’ll keep short and sweet.
If you are using a Regular Expression Validator you will have the problem that if you use a line break it won’t validate when you write something like ^.{0,n}$ even though the dot is supposed to match anything
Apparently the dot isn’t supposed to match new line characters
I took the following from http://weblogs.asp.net/cosgood/archive/2003/05/06/6604.aspx although the wrong bracket is used to close off the cardinality
^(.|\s){0,n}$
That’s it, just remember to escape the backslash depending on where you are setting the expression.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
The “dot” is supposed to match anything except the newline character. It’s pretty standard but does seem to catch a lot of people. Even your article mentions this.
Link | February 15th, 2010 at 1:27 pm
I mostly just skimmed it looking for the right info. Guess my regular expressions aren’t really up to scratch. Thanks for pointing it out, thought it was just microsoft going off standard
Link | February 15th, 2010 at 3:31 pm
Trget picked this up immediately. It didn’t click with me till I went and checked my old perl re notes.
Funnily enough I’ve never had this come up despite my extensive use of regular expressions in word sense disambiguation. I always used \S for crossing newline characters.
Link | February 17th, 2010 at 6:00 pm
Yeah, I wasn’t too surprised that it was trget who spotted that. He tends to notice these things.
Link | February 17th, 2010 at 6:26 pm