Jon Skeet <sk***@pobox.com> wrote in message news:<MP************************@news.microsoft.co m>...
^(.*escaped.*hound.*)|(.*hound.*escaped.*)$
That doesn't work (it doesn't match "Test with escaped then hound in
it") and I don't quite understand why. Any chance you could enlighten
me?
Possible bug in the .net regex engine? It parsed correctly using a java
applet I found at
http://www.cis.upenn.edu/~matuszek/G...ex-tester.html
Also in the .net regex engine the following regex seems to parse correctly
^(.+escaped.*hound.*)|(.*hound.*escaped.*)$
The regex probably doesn't really have the meaning you thought it had
though. Misplaced paranthesises causes the regex to match on either
^(.*escaped.*hound.*) or (.*hound.*escaped.*)$. Placing the whole matched
string in group 0. Group 1 or 2 will also contain the full string while
the other group will be null since only one of the two paths can be
followed.
^(.*escaped.*hound.*|.*hound.*escaped.*)$ would make the regexp a little
less complex although this expression also seems to fail in .net regex
engine.
The most practical regex if you want to use ^,$ to match the
whole row is probably
^.*(escaped.*hound|hound.*escaped).*$
It places the whole matched row in group 0 and the "escaped.....hound" in
group 1. This regex does work in the .net regex engine.
/Marcus