The RegExp object in JavaScript is an intrinsic global object that holds information about the pattern-matching of regular expressions. How to use:
Regexp.property
The mandatory option property parameter is any of the properties of the RegExp object. REGEXP objects cannot be created directly, but can always be used. Before a successful regular expression lookup is complete, the initial values for each property of the RegExp object are as follows:
Attribute shorthand initial value
Index-1www.hljmlyfcyy.com
LastIndex-1
lastmatch$& an empty string.
lastparen$+ an empty string.
Leftcontext an empty string.
Rightcontext an empty string.
$-$9$1-$9 empty string.
Before a successful regular expression lookup is complete, its property value is undefined.
Do not confuse a global RegExp object with a regular expression object. Although it sounds like one thing, they are very different. The properties of the global RegExp object contain constantly updated information about each occurrence, whereas the regular expression object contains only the information that appears to match the regular expression.
The following example illustrates the use of RegExp objects in global JavaScript.
function Matchdemo () {
var s;
var re = new RegExp ("D (b +) (d)", "IG");
var str = "CDBBDBSBDBDZ";
var arr = re.exec (str);
s = "$ contains:" + regexp.$1 + "\ n";
S + = "$ contains:" + regexp.$2 + "\ n";
S + = "$ contains:" + regexp.$3;
return (s);
}www.hrbfc120.com
RegExp objects in JavaScript