I wanted to match filenames that don't end with
.doc
and I came up with [^.]*|.*\.(?!doc)[^.]*
. Hmm, regexes are hard to read. Let's reformat... (?x) # comments and whitespace [^.]* # something with no dots | # ...or... .* # something... \. # ...with a dot... (?!doc) # ...not followed by "doc"... [^.]* # ...but followed by soemthing with no dots