What regular expression would match an occurrence of the string "war" that doesn't have the string "soft" in front of it? In other words the "war" in "world war iii" would match, but the "war" in "where's my software" would not? Further, "stay out of my warehouse" would match, so would "aware". In other words, I just don't want the string "software" to match.
If your regex engine supports lookbehinds: (?<!soft)war.
You can try it using Perl:
$ perl -ne 'print if /(?<!soft)war/i' < my-text-file
That will work more or less like grep (but grep does not support lookbehinds, afaik).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With