Reputation: 716
I'm trying to match a word ("Junior Consultant") not followed by a specific string "(m/f)" and allow multiple words (up to 5 words) in between.
Should match:
Junior Consultant in New York
Junior Consultant Banking
Junior Consultant w1 w2 w3 w4 w5
Junior Consultant w1 w2 w3 w4 w5 w6 (m/f)
Should NOT match:
Junior Consultant in New York (m/f)
Junior Consultant (m/f)
Junior Consultant w1 w2 w3 w4 w5 (m/f)
This is what I got so far:
Junior Consultant((?!\s\(m\/f\))(\s\w+)){0,5}
Upvotes: 3
Views: 62
Reputation: 47722
Almost there, but you have to match all zero to five words before the "(m/f)" part. Try this:
/Junior Consultant(?!(\s\w+){0,5}\s\(m\/f\))/
Upvotes: 3