(^[^BC]+A[^BC]+$)|(^A.*)|(.*A$)
This says:
match one of three patterns - they are each enclosed by () and separated
by | in the above
the first pattern (^[^BC]+A[^BC]+$) says:
(^ = insist on beginning of line at the start of the match
$) = insist on end-of-line for the end of the match
[^BC] = matches anything except B or C.
[^BC]+ = match a string of chars that is anything except B or C
and of course the A in the middle is the target you are matching
the 2nd pattern (^A.*) says:
match any line that begins with A: (^A
the 3rd pattern is similar, it says
match any line that ends in A : A$)
Suggestion:
Get a visual regex designer, it's a simple tool that makes things much
easier.
One I use and can recommend is Regex, freebie download from organicbit.com:
http://www.organicbit.com/regex/fog0000000019.html
--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m
"Derek Stone" <ds****@elitevb.com> wrote in message
news:eV*************@TK2MSFTNGP10.phx.gbl...
In my continuing inability to completely understand regular expressions I
have a new one for you.
I'd like to capture a string "A" unless it is anywhere in between string
"B" and string "C".
Therefore some matches are:
XYZAHIJ
ABC
BCA
Non matches include:
BAC
BXYZAHIJC
BAXYZC
Also, since I'm trying to replace "A" and only "A" the expression needs to
exclude the rest of the match. I assume that means using non-capturing
groups, but again, they and I don't mix.
Thank you,
Derek Stone
EliteVB.com