JavaScript Regex - How to Use Regular Expressions in JavaScript
JavaScript Regular Expressions
- A regular expression is a order of characters that forms to get the search pattern.
- The search pattern can be used for search and replace the text.
Sample Code
Output
Modifier | Description |
---|---|
i | Used for case-insensitive matching |
g | Used for global match find all matches rather than stopping after the first match |
m | Used for multi-line matching |
Modifier | Description |
---|---|
[abc] | Find any of the characters between the brackets |
[0-9] | Find any of the digits between the brackets |
(x|y) | Find any of the alternatives separated with | |
Modifier | Description |
---|---|
\d | Used for finding the digit |
\s | Used to find whitespace character |
\b | Finding a match at the starting of a word like this: \bJAVASCRIPT, or at the ending of a word like this: JAVASCRIPT\b |
\uxxxx | Used for findinf the Unicode character that specified by the hexadecimal number xxxx |