
1 Nov
2011
1 Nov
'11
6:15 p.m.
why is this regex const string sRe = "((([a-zA-Z]|([a-zA-Z][a-zA-Z0-9\\-]))+[a-zA-Z0-9])\\.)+" "((([a-zA-Z]|([a-zA-Z][a-zA-Z0-9\\-]))+[a-zA-Z0-9]))";
not matching this string wholly? "a1a.a2a.a3a.a4aaaa"
It rather matches only this part: "a1a.a2a.a3a.a4"
What's the problem here? (I know I can append a delimiter to solve the problem, but I think the regex should've match it wholly, shouldn't it?)
No, in Perl mode, early alternatives are preferred to later ones, so given: a|aa against: aaaa will only match the first "a". This is what's happening in your expression. HTH, John.