Reputation: 1734
Not too familiar at RE. I have the following string
"The cat jump The cat ran The cat eat The dog jump The dog ran The dog eat".
I want to get
"The cat ran" and "The dog ran".
I thought this RE using negative look ahead should work
"The(?!.*The).*jump"
but it's not. What is missing?
Please help.
Upvotes: 1
Views: 108
Reputation: 33908
Seems that you want an expression that matches a substring that does not contain The
.
That can be done with a construct like (?:(?!The).)*
, in your expression:
The(?:(?!The).)*jump
Note that in this case using lazy (.*?
) quantifiers would suffice, eg:
The.*?jump
Maybe that can work on your original problem too.
Upvotes: 1