I want to match all lines that start with fn-
except ones that use specific words after the hyphen.
match:
fn-bar
fn-foo
fn-foobarb
dont match ( foobar
and fubar
are my exact negative filters):
fn-foobar
fn-fubar
xn-blah
So far I have:
(fn)-(?!(fubar|foobar)$)
which does not match the whole line
You can use the word delimiter \b
to avoid matching the " foobar " and " fubar " words. Instead in order to avoid whole line issue, it's sufficient to antepose the negation of the full phrases you don't want to match.
(?!fn-foobar\b|fn-fubar\b)fn-.*
Check the demo here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.