JavaScript RegExp Complete Reference
The RegExp stands for Regular Expression. A regular expression is a sequence of characters that forms a search pattern. The search pattern can be used for text search and text to replace operations. A regular expression can be a single character or a more complicated pattern.
Syntax:
new RegExp("(Regular Expressioncharactersnonword)")Example: This example searches the words whose starting character is “A” and ending character is “C” with only one character in between them.
HTML
<!DOCTYPE html><html> <body style="text-align:center"> <h1 style="color:green"> GeeksforGeeks </h1> <h2>RegExp . Metacharacter</h2> <p> Input String: ABC, A3C, A C, AXXCC! </p> <button onclick="geek()"> Click it! </button> <p id="app"></p> <script> function geek() { var str1 = "ABC, A3C, A C, AXXCC!"; var regex4 = /A.C/g; var match4 = str1.match(regex4); document.getElementById("app").innerHTML = "Found " + match4.length + " matches: " + match4; } </script> </body></html> |
Output:

The complete list of JavaScript RegExp is listed below:
JavaScript RegExp | Description |
|---|---|
| JavaScript RegExp . Metacharacter | The RegExp . Metacharacter in JavaScript is used to search single characters, except line terminator or newline. |
| JavaScript RegExp m Modifier | The RegExp m Modifier in JavaScript is used to perform multiline matching. |
| JavaScript RegExp \r Metacharacter | The RegExp \r Metacharacter in JavaScript is used to find the carriage return character (Carriage return means to return to the beginning of the current line without advancing downward). |
| JavaScript RegExp (x|y) Expression | The RegExp (x|y) Expression in JavaScript is used to search any of the specified characters (separated by |). |
| JavaScript RegExp \xxx Metacharacter | The RegExp \xxx Metacharacter in JavaScript is used to find the character specified by an octal number xxx. |
| JavaScript RegExp \W Metacharacter | The RegExp \W Metacharacter in JavaScript is used to find the non word character i.e. characters which are not from a to z, A to Z, 0 to 9. It is thethatthe same as [^a-zA-Z0-9]. |
| JavaScript RegExp [^abc] Expression | The RegExp [^abc] Expression in JavaScript is used to search for any character which is not between the brackets. |
| JavaScript RegExp g Modifier | The RegExp g Modifier in JavaScript is used to find all the occurrences of the pattern instead of stopping after the first match i.e it performs a global match. |
| JavaScript RegExp [0-9] Expression | The RegExp [0-9] Expression in JavaScript is used to search any digit which is between the brackets. |
| JavaScript RegExp \s Metacharacter | The RegExp \s Metacharacter in JavaScript is used to find the whitespace characters. |
| JavaScript RegExp \b Metacharacter | The RegExp \b Metacharacter in JavaScript is used to find a match at the beginning or end of a word |
| JavaScript RegExp i Modifier | The RegExp i Modifier in JavaScript is used to perform case-insensitive matching in the string. |
| JavaScript RegExp \n Metacharacter | The RegExp \n Metacharacter in JavaScript is used to find the newline character. |
| JavaScript RegExp [^0-9] Expression | The RegExp [^0-9] Expression in JavaScript is used to search for any digit which is not between the brackets. |
| JavaScript RegExp \B Metacharacter | The RegExp \B Metacharacter in JavaScript is used to find a match that is not present at the beginning or end of a word. |
| JavaScript RegExp \f Metacharacter | The RegExp \f Metacharacter in JavaScript is used to find the form feed character (form feed is a page-breaking ASCII control character). |
| JavaScript RegExp \w Metacharacter | The RegExp \w Metacharacter in JavaScript is used to find the word character i.e. characters from a to z, A to Z, 0 to 9. It is the same as [a-zA-Z_0-9]. |
| JavaScript RegExp \d Metacharacter | The RegExp \d Metacharacter in JavaScript is used to search digit characters. It is the same as [0-9]. |
| JavaScript RegExp \t Metacharacter | The RegExp \t Metacharacter in JavaScript is used to find the tab character. If it is found it returns the position else it returns -1. |
| JavaScript RegExp \D Metacharacter | The RegExp \D Metacharacter in JavaScript is used to search non-digit characters i.e all the characters except digits. It is the same as [^0-9]. |
| JavaScript RegExp \0 Metacharacter | The RegExp \0 Metacharacter in JavaScript is used to find the NULL character. If it is found it returns the position else it returns -1. |
| JavaScript RegExp \v Metacharacter | The RegExp \v Metacharacter in JavaScript is used to find the vertical tab character. If it is found it returns the position else it returns -1. |
| JavaScript RegExp * Quantifier | The RegExp m* Quantifier in JavaScript is used to find the match of any string that contains zero or more occurrences of m. |
| JavaScript RegExp {X,} Quantifier | The RegExp m{X, } Quantifier in JavaScript is used to find the match of any string that contains a sequence of m, at least X times, where X is a number. |
| JavaScript RegExp ?! Quantifier | The RegExp ?!m Quantifier in JavaScript is used to find the match of any string which is not followed by a specific string m. |
| JavaScript RegExp {X} Quantifier | The RegExp m{X} Quantifier in JavaScript is used to find the match of any string that contains a sequence of m, X times where X is a number. |
| JavaScript RegExp ^ Quantifier | The RegExp ^m Quantifier in JavaScript is used to find the match of any string which contains m at the beginning of it. |
| JavaScript RegExp ? Quantifier | The m? a quantifier in JavaScript is used to find the match of any string that contains zero or one occurrence of m. |
| JavaScript RegExp $ Quantifier | The RegExp m$ Quantifier in JavaScript is used to find the match of any string which contains m at the end of it. |
| JavaScript RegExp + Quantifier | The m+ Quantifier in JavaScript is used to find the match of any string that contains at least one m. |
| JavaScript RegExp \uxxxx Metacharacter | The RegExp \uxxxx Metacharacter in JavaScript is used to find the Unicode character specified by a hexadecimal number XXXX. |
| JavaScript RegExp {X,Y} Quantifier | The RegExp m{X, Y} Quantifier in JavaScript is used to find the match of any string that contains a sequence of m, X to Y times where X, Y must be numbered. |
| JavaScript RegExp toString() Method | The RegExp toString() Method in JavaScript is used to return the string value of the regular expression. |
| JavaScript RegExp test() Method | The RegExp test() Method in JavaScript is used to test for the match in a string. If there is a match this method returns true else it returns false. |
| JavaScript RegExp ignoreCase Property | The RegExp ignoreCase property in JavaScript is used to specify whether the “i” modifier is set or not |
| JavaScript RegExp constructor | The RegExp constructor in JavaScript is used to return the function that created the RegExp |






Please Login to comment...