JavaScript RegExp object
Regular expressions are objects that describe patterns of characters.
Regular expressions are used for pattern matching and retrieval and replacement of strings, and are powerful tools for performing pattern matching on strings.
grammar
var patt=new RegExp(pattern,modifiers); or the simpler way: var patt = / pattern / modifiers;
- pattern (pattern) describes the pattern of the expression
- modifiers are used to specify global matching, case-sensitive matching, and multi-line matching
Note: When using the constructor to create regular objects, the normal character escaping rules (preceding backslash \) are required.
modifier
Modifiers are used to perform case-sensitive and global matching:
Square brackets
Square brackets are used to find a range of characters:
metacharacter
Metacharacters are characters with special meanings:
quantifier
Methods of String objects that support regular expressions
Excerpted from the Reference Manual for the JavaScript RegExp Object of the Rookie Tutorial