[Regex]::Matches($string, '(?:^|\b)words(?:$|\b)')
DetailsMatches only the specific word in the express. In this case words will return, but passwords will not.
Example
PS C:\> $string = 'A passwords should not contain words found in the dictionary.' >> [Regex]::Matches($string, '(?:^|\b)words(?:$|\b)') Groups : {0} Success : True Name : 0 Captures : {0} Index : 31 Length : 5 Value : words
Share this:
- Click to share on LinkedIn (Opens in new window)
- Click to share on Mastodon (Opens in new window)
- Click to share on Bluesky (Opens in new window)
- Click to share on Reddit (Opens in new window)
- Click to share on Twitter (Opens in new window)
- Click to share on Facebook (Opens in new window)
- Click to email a link to a friend (Opens in new window)