user1990903
user1990903

Reputation: 1

Regular Expression check for no string

I want to find from a list of strings (all captial letters) that contains "NAME", but before and after the name I don't want any characters. So I tried this regex "[^A-Z]NAME[^A-Z]. But the string that are like "NAME", or "NAME " can not be matched, I thought the [^A-Z] just check as long they are not in these character, and nothing would also be OK. Did I miss something here?

Chris

Upvotes: 0

Views: 76

Answers (1)

Joseph Silber
Joseph Silber

Reputation: 219938

Try using a word boundry:

\bNAME\b

Here's a demo: http://regexr.com?33f1d

Upvotes: 1

Related Questions