Javascript Reference
Categories: regular expression

javascript regular expression exec( )

@March 15, 2008, 1:22 a.m.
exec( )Firefox/Netscape/NN 4 IE 4 ECMA 3  

exec(string)

  

Performs a search through the string passed as a parameter for the current regular expression pattern. A typical sequence follows the format:

var myRE = /somePattern/;
var resultArray = myRE.exec("someString");
 

Properties of both the static RegExp and regular expression instance (myRE in the example) objects are updated with information about the results of the search. In addition, the exec( ) method returns an array of data, much of it similar to RegExp object properties. The returned array includes the following properties:

index

Zero-based index of starting character in the string that matches the pattern

input

The original string being searched

[0]

String of the characters matching the pattern

[1]...[n]

Strings of the results of the parenthesized component matches

 

You can stow away the results of the exec( ) method in a variable, whereas the RegExp property values change with the next regular expression operation. If the regular expression is set for global searching, a subsequent call to myRE.exec("someString") continues the search from the position of the previous match.

 

If no match is found for a given call to exec( ), it returns null.

 
Parameters
 
  • The string to be searched.
 
Returned Value

An array of match information if successful; null if there is no match.

order lipitor 20mg generic <a href="https://lipiws.top/">atorvastatin 20mg pills</a> buy generic atorvastatin 10mg
Llxgrs - 9 months
atorvastatin 40mg canada <a href="https://lipiws.top/">lipitor order</a> buy lipitor generic
Bbdibd - 9 months

Powered by Linode.