Reputation: 3
I am trying to filter all files not ending with, for instance mp3
or wv
.
I have tried to use something like this ^.*(?<![mp3|wv])$
but this expression doesn't work.
Please help to create valid expression.
Upvotes: 0
Views: 62
Reputation: 89557
Since a lookbehind is a zero-width assertion, you can write:
^.*(?<!mp3)(?<!wv)$
or better ($ is a zero-width assertion too):
^.*$(?<!mp3)(?<!wv)
if your regex flavor allows it (PCRE, Java), you can use an alternation:
^.*$(?<!mp3|wv)
Note: if your goal is only to know if a string doesn't end with "vw" or "mp3", you can test if (?:mp3|wv)$
is false.
Upvotes: 3