regex line not containing word? -


i'm hoping can me possibly simple regex question. need match lines contain set of words, not contain word.

e.g. file searching contains following:

bob has hat.
bill has hat.
fred has hat.

what want match lines have 'has hat.' unless line contains bob.

does make sense ?

this has basic regex, not code or entering text file parse program.

^(?=.*\bhas hat\b)(?!.*\bbob\b).* 

matches entire line if contains has hat anywhere , doesn't contain bob anywhere (in order).

of course, not match line fred has hat. bob doesn't.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -