A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/RegExp below:

RegExp ยท WebPlatform Docs

RegExp Summary

An intrinsic global object that stores information about the results of regular expression pattern matches.

Syntax
RegExp.property
Examples

The following example performs a regular expression search. It displays matches and submatches from the global RegExp object, and from the array that is returned by the exec method.

var newLine = "<br />";

 var re = /(\w+)@(\w+)\.(\w+)/g
 var src = "Please send mail to george@contoso.com and someone@example.com. Thanks!"

 var result;
 var s = "";

 
 result = re.exec(src);

 while (result != null) {
     
     s += newLine;

     
     s += "RegExp.lastMatch: " + RegExp.lastMatch + newLine;
     s += "RegExp.: " + RegExp. + newLine;
     s += "RegExp.: " + RegExp. + newLine;
     s += "RegExp.: " + RegExp. + newLine;

     
     
     for (var index = 0; index < result.length; index++) {
         s +=  index + ": ";
         s += result[index];
         s += newLine;
     }

     
     result = re.exec(src);
 }
 document.write(s);

 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
Remarks

The required property argument can be any one of the RegExp object properties.

The RegExp object cannot be created directly, but is always available for use. Until a successful regular expression search has been completed, the initial values of the various properties of the RegExp object are as follows:

Its properties have undefined as their value until a successful regular expression search has been completed.

The global RegExp object should not be confused with the Regular Expression object. Even though they sound like the same thing, they are separate and distinct. The properties of the global RegExp object contain continually updated information about each match as it occurs, while the properties of the Regular Expression object contain only information about the matches that occur with that instance of the Regular Expression.

Properties

||
|global|Returns a Boolean value indicating the state of the global flag ( g ) used with a regular expression.|
|ignoreCase|Returns a Boolean value indicating the state of the ignoreCase flag ( i ) used with a regular expression.|
|multiline|Returns a Boolean value indicating the state of the multiline flag ( m ) used with a regular expression.|
|source|Returns a copy of the text of the regular expression pattern.|
|sticky|Returns a Boolean value indicating the state of the sticky flag ( y ) used with a regular expression.|
|unicode|Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular expression.|

Methods

||
|compile|Compiles a regular expression into an internal format for faster execution.|
|exec|Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.|
|test|Returns a Boolean value that indicates whether or not a pattern exists in a searched string.|

Properties

The following table lists the properties of the RegExp object.

Property Summary global Returns a Boolean value indicating the state of the global flag ( g ) used with a regular expression. Default is false. Read-only. ignoreCase Returns a Boolean value indicating the state of the ignoreCase flag ( i ) used with a regular expression. Default is false. Read-only. multiline Returns a Boolean value indicating the state of the multiline flag ( m ) used with a regular expression. Default is false. Read-only. source Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. sticky Returns a Boolean value indicating the state of the sticky flag ( y ) used with a regular expression. Default is false. Read-only. unicode Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular expression. Default is false. Read-only. Functions

The following table lists the functions of the RegExp object.

Methods

The following table lists the methods of the RegExp object.

Method Summary compile Compiles a regular expression into an internal format for faster execution. exec Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. test Returns a Boolean value that indicates whether or not a pattern exists in a searched string. See also Other articles Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4