Regular expression to match text that doesn't start with substring?
Posted
by Steven
on Stack Overflow
See other posts from Stack Overflow
or by Steven
Published on 2010-03-21T05:23:45Z
Indexed on
2010/03/21
5:31 UTC
Read the original article
Hit count: 157
regex
I have text with file names scattered throughout. The filenames appear in the text like this:
|test.txt|
|usr01.txt|
|usr02.txt|
|foo.txt|
I want to match the filenames that don't start with usr
. I came up with (?<=\|).*\.txt(?=\|)
to match the filenames, but it doesn't exclude the ones starting with usr
. Is this possible with regular expressions?
© Stack Overflow or respective owner