I would like to find some words not surrounded by any numerics or alphanumerics or surrounded by nothing.
So if I’m looking for Foo123 I would like this result
="Foo123"; =>TRUE
barFoo123; =>FALSE
Foo123 =>TRUE
BarBar123Foo123Bar; =>FALSE
;Foo123 =>TRUE
I just built this expression:
(^[^0-9a-zA-Z]?)WORDTOFIND([^0-9a-zA-Z]?$)
I was pretty sure I’m in the right way but when I’m using it like this:
if (Regex.IsMatch(line, string.Format(@"(^[^0-9a-zA-Z]?){0}([^0-9a-zA-Z]?$)",snCode)) )
{
}
It doesn’t work. What am I doing wrong?
You’re essentially looking for
This uses a lookahead and lookbehind to make sure that there isn’t an alphanumeric character either before or after
Foo123. This assumes ASCII, though.