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 wan开发者_开发知识库t a match on the first string
banana.*(?<!(\bnot ))inc(\.|luded)?
What am I missing in my regex to achieve my desired result.
Thanks!
It's hard to tell from only two examples, but perhaps this is what you want?
banana(?!.*\bnot\b).*\binc(\.|luded)?
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.
精彩评论