JS Built-ins
RegExpbeginner

RegExp Constructor β€” literal test

πŸ“– Usage Example
const re1 = /hello/i
const re2 = new RegExp('hello', 'i')
re1.test('Hello world') // β†’ true

Use the RegExp constructor or literal syntax to create a regular expression.

RegExp Constructor

A RegExp literal /pattern/ creates a regular expression object.

Challenge: Verify that /hello/.test('hello world') returns true.

πŸ’‘ Hints (1)
  • β€’ RegExp literals are written between forward slashes