$ ./guess_the_languageRegex
Regex · medium · #50

What does this expression return?

'a.b*c'.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
  1. 'a\.b\*c'
  2. 'a\$&b\$&c'
  3. 'a.b*c'
  4. 'a\\.b\\*c'
$& inserts the whole match, so each special character gets a backslash in front of it.
Play Regex ▸