October 26th, 2010, 03:10 PM
I have a regular expression.
According to documentation "." is any character except \n
? is zero or one times preceding character.
string "a" matches.
"aa" does not match. Should "aa" match?
"ab" does not match. Should it match?
Can an guru explain me this please?
October 27th, 2010, 05:01 AM
Re: Regular Expression
No, it shouldn't because of ^ and $ in regular expressionm, which means begin and end of line including and the expression is evaluated as a whole. Your expression means begin-zero or just one chars-ends, but in these samples, the pattern is begin-first char-second char-end, which doesn't match, because the end of line is expected after max one char, not two.
Originally Posted by gulumal
Don't hesitate to rate my post.
- Make it run.
- Make it right.
- Make it fast.
Click Here to Expand Forum to Full Width