If you want to match the "foo" part only, use this:
((?<=(bar|bar1).*)foo|foo(?=.*(bar|bar1)))
If you want to match the whole line, use this:
..*(bar|bar1).*foo.*|.*foo.*(bar|bar1).*
If you don't really need the matched text and just need to know if there is
a match, use the IsMatch function with either of these.
Also, I am assuming that you really aren't going to be looking for the
literals "bar" or "bar1". If for some reason you were, then you would only
need to look for "bar" since it is contained within "bar1".
Brian Davis
www.knotdotnet.com
"Scott Turner" <sc***@prorege.com> wrote in message
news:d3**************************@posting.google.c om...
I need help creating a regular expression which will match the following:
"foo" anywhere in the text
Also the text should contain either "bar" or "bar1"
Following are some examples of text which should return a match:
xxxx foo xxxx xxx bar xxxx
xxxx foo xxxx xxx bar1 xxxx
xxxx bar xxxxxxx foo xxxxx xxxx
xxxx bar1 xxxxxxx foo xxxxx xxxx
xxxx bar1 xxxx bar xxx foo xxxxx xxxx
xxx foo xxxxx xxxx xxxx bar1 xxxx bar
Thanks,
Scott