I should preface this by stating that I\'m working with VB6 & RegExp
I\'m attempting to find and substitute whole words, by \"whole words\" I mean a valid match
Use the "word boundary" expression \b
.
Perhaps something as simple as this will do:
(.*)\bFoo\b(.*)
FYI, the word boundary expression \b
is a zero-width match between a word character \w
and a non-word character [^\w]
or visa versa, and consumes no input.
Underscore and digit characters are considered "word characters", so Foo_Bar
, Bar_Foo
, and Foo123
wouldn't match. To rectify that, so that any non-letter is considered "end of word" (including start and end of input), use look arounds:
(?i)(.*(?