I need to match all of its lines that contains a value and that don't have a given prefix.
Example: I want all lines that contains word
when it's not prefixed by prefix
So:
foobar -> no match prefix word -> no match prefix word suffix -> no match word -> MATCH something word -> MATCH
What I've tried so far:
(?!prefix)word
Doesn't seem to do what I want
To match any character except a list of excluded characters, put the excluded charaters between [^ and ] . The caret ^ must immediately follow the [ or else it stands for just itself. The character '. ' (period) is a metacharacter (it sometimes has a special meaning).
\n. Matches a newline character. \r. Matches a carriage return character.
\\. matches the literal character . . the first backslash is interpreted as an escape character by the Emacs string reader, which combined with the second backslash, inserts a literal backslash character into the string being read. the regular expression engine receives the string \.
You may need
(?<!prefix )word
(and maybe take care of the spaces).
(?!)
is a negative lookahead but in your case you need a negative lookbehind (i.e. (?<!)
).
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