All files ending with a suffix without using negation

I am trying to match all files except those ending in .bmp.

Due to some restrictions, I cannot use negation (?:,! :) and links (\ 1, ...).

I made an expression and it works for most lines:

^\w+\.([^b].*|b|b[^m].*|bm|bm[^p].*|bmp.+)$

It matches everything that doesn't end with .bmp - including test.txt, test.bmp.txt, etc. But dishonestly, it allows test.bi.bmp.

Any idea on how to improve the regex so that it matches files not ending in .bmp?

+5
source share
3 answers

why not:

^.*[^p]$|^.*[^m]p$|^.*[^b]mp$|^.*[^.]bmp$

?

http://regexr.com?31vg7

Alternative ^.*([^p]|[^m]p|[^b]mp|[^.]bmp)$(in short).

+5
source
/^.+\.([^b][^.]*|b|b[^m][^.]*|bm|bm[^p][^.]*|bmp[^.]+)$/

, 'bmp'

+1

, :

^.*([^b][^m][^p]|b[^m][^p]|[^b]m[^p]|[^b][^m]p|bm[^p]|[^b]mp)$
0

All Articles