These are properties containing parenthized substrings (if any) from a regular expression.
These
are properties containing parenthesized substrings (if any) from a regular
expression. The number of parenthesized substrings is unlimited, but these
properties only hold the last nine. All parenthesized substring, however,
can be accessed throught the returned array's indexes. When used as the
second argument of the String.replace method, these properties
do not require RegExp. before them.
NOTE:
Because input is static, it is always used as RegExp.input
myRegExp = /(\d{2})\W(\d{2})\W(\d{4})/
dateString = "25/12/1997"
newString = dateString.replace(myRegExp, "$2/$1/$3")
document.write(newString) 12/25/1997In this example, the day and month parts of a date written in British format are rearranged to American style.