$ ./guess_the_languageRegex
Regex · medium · #22

What does this expression return?

'cat concat'.replace(/\Bcat/g, 'X')
  1. 'cat conX'
  2. 'X conX'
  3. 'X concat'
  4. 'cat concat'
\B is a non-boundary, so it only matches "cat" when it is preceded by another word character.
Play Regex ▸