0% found this document useful (0 votes)
2 views10 pages

JavaScript RegExp Reference

The document provides a reference for the JavaScript RegExp object, which describes patterns of characters used for pattern matching and search-and-replace functions. It includes syntax, modifiers, metacharacters, quantifiers, and methods associated with regular expressions. Additionally, it outlines properties of the RegExp object and examples of usage.

Uploaded by

Chris Ruga
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

JavaScript RegExp Reference

The document provides a reference for the JavaScript RegExp object, which describes patterns of characters used for pattern matching and search-and-replace functions. It includes syntax, modifiers, metacharacters, quantifiers, and methods associated with regular expressions. Additionally, it outlines properties of the RegExp object and examples of usage.

Uploaded by

Chris Ruga
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript RegExp Reference [Link]

asp

[Link]
THE WORLD'S LARGEST WEB DEVELOPER SITE

JavaScript RegExp Reference


❮ Previous Next ❯

RegExp Object
A regular expression is an object that describes a pattern of
characters.

Regular expressions are used to perform pattern-matching


and "search-and-replace" functions on text.

Syntax
/pattern/modifiers;

Example

var patt = /w3schools/i

Example explained:

/w3schools/i is a regular expression.


w3schools is a pattern (to be used in a search).
i is a modifier (modifies the search to be

1 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   

JavaScript Reference
Overview
Modifiers
Modifiers are used to perform case-insensitive and global
JavaScript searches:

JS String
Modifier Description
JS Number
Perform case-insensitive matching
JS Operators
JS Statements g Perform a global match (find all matches
rather than stopping after the first match)
JS Math
JS Date m Perform multiline matching

JS Array
JS Boolean Brackets
JS Error
Brackets are used to find a range of characters:
JS RegExp
JS Global Expression Description

JS Conversion [abc] Find any character between the brackets

[^abc] Find any character NOT between the


Browser BOM
brackets
Window
[0-9] Find any digit between the brackets
Navigator
Screen [^0-9] Find any digit NOT between the brackets

History (x|y) Find any of the alternatives specified


Location

Metacharacters
HTML DOM
Metacharacters are characters with a special meaning:
DOM Document
DOM Elements

2 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   
or line terminator

JavaScript Reference \w Find a word character

Overview \W Find a non-word character

\d Find a digit
JavaScript
\D Find a non-digit character
JS String
\s Find a whitespace character
JS Number
JS Operators \S Find a non-whitespace character

JS Statements \b Find a match at the beginning/end of a


JS Math word

JS Date \B Find a match not at the beginning/end


JS Array of a word

JS Boolean \0 Find a NUL character


JS Error
\n Find a new line character
JS RegExp
\f Find a form feed character
JS Global
JS Conversion \r Find a carriage return character

\t Find a tab character


Browser BOM
\v Find a vertical tab character
Window
\xxx Find the character specified by an octal
Navigator
number xxx
Screen
\xdd Find the character specified by a
History
hexadecimal number dd
Location
\uxxxx Find the Unicode character specified by
a hexadecimal number xxxx
HTML DOM
DOM Document
DOM Elements
Quantifiers

3 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   
one n

JavaScript Reference n* Matches any string that contains zero or


more occurrences of n
Overview
n? Matches any string that contains zero or
one occurrences of n
JavaScript
n{X} Matches any string that contains a
JS String
sequence of X n's
JS Number
n{X,Y} Matches any string that contains a
JS Operators
sequence of X to Y n's
JS Statements
n{X,} Matches any string that contains a
JS Math
sequence of at least X n's
JS Date
n$ Matches any string with n at the end of it
JS Array
JS Boolean ^n Matches any string with n at the beginning
of it
JS Error
JS RegExp ?=n Matches any string that is followed by a
specific string n
JS Global
?!n Matches any string that is not followed by a
JS Conversion
specific string n

Browser BOM
Window
RegExp Object Properties
Navigator
Property Description
Screen
constructor Returns the function that created the
History
RegExp object's prototype
Location
global Checks whether the "g" modifier is set

HTML DOM ignoreCase Checks whether the "i" modifier is set

DOM Document lastIndex Specifies the index at which to start the


DOM Elements

4 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   
source Returns the text of the RegExp pattern
JavaScript Reference
Overview RegExp Object Methods
JavaScript Method Description

JS String compile() Deprecated in version 1.5. Compiles a


JS Number regular expression

JS Operators exec() Tests for a match in a string. Returns the


JS Statements first match

JS Math test() Tests for a match in a string. Returns true


JS Date or false

JS Array toString() Returns the string value of the regular


JS Boolean expression

JS Error
JS RegExp
❮ Previous Next ❯
JS Global
JS Conversion

Browser BOM
Window
Navigator
Screen
History
Location

HTML DOM
DOM Document
DOM Elements

5 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   

JavaScript Reference
Overview

JavaScript
JS String
JS Number
JS Operators
JS Statements
JS Math
JS Date
JS Array
JS Boolean
JS Error
JS RegExp
JS Global
JS Conversion

Browser BOM COLOR PICKER


Window
Navigator
Screen
History
LEARN MORE
Location
Convert Weights
HTML Cards
HTML DOM Google Maps
DOM Document Animated Buttons
Modal Boxes
DOM Elements

6 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   
Filter List
JS Animations
JavaScript Reference Progress Bars
Dropdowns
Overview Slideshow
Accordions
JavaScript Side Navigation
Top Navigation
JS String HTML Includes
JS Number Tabs

JS Operators
JS Statements
SHARE

JS Math   
JS Date
JS Array

JS Boolean
CERTIFICATES
JS Error
JS RegExp HTML, CSS, JavaScript, PHP, jQuery, Bootstrap and XML.

JS Global Read More »


JS Conversion

Browser BOM
Window
Navigator
Screen
History
Location

HTML DOM
DOM Document
DOM Elements

7 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   

JavaScript Reference
Overview

JavaScript
JS String
JS Number
JS Operators
JS Statements
JS Math
JS Date
JS Array
JS Boolean
JS Error
JS RegExp
JS Global
JS Conversion

Browser BOM
Window
Navigator
Screen
History
Location

HTML DOM
DOM Document
DOM Elements

8 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

☰  HTML CSS JAVASCRIPT MORE 

REFERENCES   

JavaScript Reference
Overview

JavaScript
JS String
JS Number
JS Operators REPORT ERROR
PRINT PAGE
JS Statements FORUM
ABOUT
JS Math
JS Date
JS Array Top 10 Tutorials
JS Boolean HTML Tutorial
CSS Tutorial
JS Error JavaScript Tutorial
[Link] Tutorial
JS RegExp Bootstrap Tutorial
JS Global SQL Tutorial
PHP Tutorial
JS Conversion jQuery Tutorial
Angular Tutorial
XML Tutorial
Browser BOM
Top 10 References
Window
HTML Reference
Navigator CSS Reference
JavaScript Reference
Screen [Link] Reference
Browser Statistics
History PHP Reference
HTML Colors
Location
HTML Character Sets
jQuery Reference
AngularJS Reference
HTML DOM
DOM Document
Top 10 Examples
HTML Examples
DOM Elements

9 of 10 12/22/2016 12:51 PM
JavaScript RegExp Reference [Link]

CSS Examples
☰  HTML CSS JAVASCRIPT MORE  Examples
JavaScript
[Link] Examples
HTML DOM Examples
REFERENCES   
PHP Examples
ASP Examples
jQuery Examples
JavaScript Reference Angular Examples
XML Examples
Overview
Web Certificates
JavaScript HTML Certificate
HTML5 Certificate
JS String CSS Certificate
JavaScript Certificate
JS Number jQuery Certificate
PHP Certificate
JS Operators Bootstrap Certificate
JS Statements XML Certificate

JS Math
JS Date
JS Array
JS Boolean
JS Error
JS RegExp
JS Global
JS Conversion

Browser BOM
Window
Navigator
Screen
History
Location

HTML DOM
DOM Document
DOM Elements

10 of 10 12/22/2016 12:51 PM

You might also like