JSFiddle - React, Tailwind, and code Playground

JavaScript

console.log('Regexp literal:', /\w+/.test('abcd'));
console.log('Regexp constructed from string with "\\w":', RegExp('\w+').test('abcd'));
console.log('Regexp constructed from string with "\\\\w":', RegExp('\\w+').test('abcd'));