regular expression — NN 4 IE J3 ECMA n/a
A regular expression object is an
instance of the
RegExp object. Each regular
expression object consists of a pattern that is used to locate
matches within a string. Patterns for a regular expression can be
simple strings or significantly more powerful expressions that use a
notation that is essentially a language unto itself. The
similar to the way they are implemented in Perl. You can read more
To create a regular expression object, surround the pattern with forward slashes, and assign the whole expression to a variable. For example, the following statement creates a regular expression whose pattern is a simple word:
var re = /greet/
re variable can then be used as a parameter in
a variety of methods that search for the pattern within some string
(you may also use an expression directly as a method parameter,
rather than assigning it to a variable).
Regular expression notation also consists of a number of metacharacters that stand in for sometimes complex ideas, such as the boundary on either side of a word, any numeral, or one or more characters. For example, to search for the pattern of characters shown above but only when the pattern is a word (and not part of a word such as greetings), the regular expression notation uses the metacharacters to indicate that the pattern includes word boundaries on both ...