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
Post a Comment