sajad torkamani

In a nutshell

A word boundary is a special anchor in Regex that matches the position between a word character ([A-Za-z0-9_]) and a non-word character. It’s written as:

\b

For example, given this string:

"hello there!"

\bhello\b will match "hello" because:

  • "hello" has a word boundary before it (the start or end of strings are considered a boundary).
  • And a space after it (a space is a non-word character).

Tagged: Regex