JavaScript - RegExp

The JavaScript RegExp, short for Regular Expression, is a pattern-matching object that provides a way to search, replace and manipulate strings. Regular expressions are written between two slashes / and can contain special characters and patterns to match, replace or manipulate strings.

Following are example cases of JavaScript Regular Expressions:

Searching for a pattern within a string: /pattern/g.test(string)

Replacing a pattern within a string: string.replace(/pattern/g, "replacement")

Extracting substrings based on a pattern: string.match(/pattern/g)

Regular expressions are written between two slashes / and can contain special characters and patterns to match, replace or manipulate strings. They can be used with various string methods such as String.match(), String.replace(), String.search(), and RegExp.exec().