I am a PowerShell newbie and I have a string in $line.
How do I test that $line has the word “Bat”, such that it succeeds for the string “Bat man”, but fails for “Batman”?
In other words, I want to test for a standalone word, not a string sequence that is part of a word.
Use word boundary a metacharacter for regex. The metacharacter
\bis an anchor like the caret and the dollar sign. It matches at a position that is called a “word boundary”.