JavaScript RegExp

You are Here:

RegExp Modifiers

The following table provides a list of all RegExp modifiers available in JavaScript.

ModifierExplanation
iPerform case-insensitive match and returns the first match
gPerform a global match and returns all matches
mPerform multiline match and returns the first match

RegExp Brackets

The following table provides a list of all RegExp brackets available in JavaScript.

BracketExplanation
[abc]Finds any character(s) in/between the brackets
[^abc]Finds any character NOT in/between the brackets
[0-9]Finds any character (digit) in/between the brackets
[^0-9]Finds any character (digit) NOT in/between the brackets
(x|y)Find any of the alternatives specified

RegExp Metacharacters

The following table provides a list of all RegExp metacharacters available in JavaScript.

MetacharacterExplanation
.Matches any single character except the newline characters (\n, \r, etc.)
\wFind a word character
\WFind a non-word character
\dFind a digit
\DFind a non-digit character
\sFind a whitespace character
\SFind a non-whitespace character
\bFinds a match at the beginning or end of a word
\BFinds a match, but where it is NOT at the beginning/end of a word
\0Finds a position (index value) of first occurrence of NUL character
\nFinds a position (index value) of first occurrence of newline character
\fFinds a position (index value) of first occurrence of form feed character
\rFinds a position (index value) of first occurrence of carriage return character
\tFinds a position (index value) of first occurrence of tab character
\vFinds a position (index value) of first occurrence of vertical tab character
\dddFinds the Latin character specified by an octal number ddd
\xddFinds the Latin character specified by a hexadecimal number dd
\uxxxxFinds the Unicode character specified by a hexadecimal number xxxx

RegExp Quantifiers

The following table provides a list of all RegExp quantifiers available in JavaScript.

QuantifierExplanation
q+Matches any string that contains at least one q
q*Matches any string that contains zero or more occurrences of q
q?Matches any string that contains zero or one occurrences of q
q{X}Matches any string that contains a sequence of X q's
q{X,Y}Matches any string that contains a sequence of X to Y q's
q{X,}Matches any string that contains a sequence of at least X q's
q$Matches any string with q at the end of it
^qMatches any string with n at the beginning of it
?=qMatches any string that is followed by a specific string q
?!qMatches any string that is not followed by a specific string q

RegExp Properties

The following table provides a list of all RegExp properties available in JavaScript.

PropertyExplanation
ConstructorReturns the function that created the RegExp object's prototype
globalIndicates whether the global match flag is specified or not
ignoreCaseIndicates whether the case-insensitive match flag is specified or not
lastIndexReturns an integer that specifies the character position immediately following the last match
multilineIndicates whether the multiline match flag is specified or not
sourceReturns a string containing the source text of the regexp object

RegExp Methods

The following table provides a list of all RegExp methods available in JavaScript.

MethodExplanation
exec()Tests for a match in a string and returns the first match
test()Tests for a match in a string and returns true or false
toString()Returns the string value of the regular expression

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author