tags:

views:

43

answers:

2

Hi,

If i have these strings:

banana not included. apple included.
banana, apple included.

the regex below returns a match on both strings but I don't want a match on the first string

banana.*(?<!(\bnot ))inc(\.|luded)?

What am I missing in my regex to achieve my desired result.

Thanks!

+1  A: 

It's hard to tell from only two examples, but perhaps this is what you want?

banana(?!.*\bnot\b).*\binc(\.|luded)?
Laurence Gonsalves
Thanks Laurence!I think we are close but I found another variation where the string is "orange included. banana included. apple not included.". This does not give me a match.Thanks again, I really appreciate your help.
Jaime
A: 

I don't have a better solution than Laurence, but to answer the why portion of your question, I believe that the .* has already consumed the not that your lookbehind is looking for.

Emily