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/1_9_Properties below:

1...9 Properties · WebPlatform Docs

1...9 Properties Summary

Return the nine most-recently memorized portions found during pattern matching. Read-only.

Syntax
RegExp.$ n
'RegExp’
Always the global RegExp object.
n
Any integer from 1 through 9.
Examples

The following example performs a regular expression search. It displays matches and submatches from the global RegExp object. The submatches are successful parenthesized matches that are contained in the properties. The example also displays matches and submatches 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 values of the $1…$9 properties are modified whenever a successful parenthesized match is made. Any number of parenthesized substrings may be specified in a regular expression pattern, but only the nine most recent can be stored.

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