August 1999
Intermediate to advanced
1488 pages
72h 53m
English
RegExp.$1,$2,..$9
The RegExp.$1,$2,..$9 property represents parenthesized substring matches.
Listing 6.213 shows how RegExp.$1,$2,..$9 is used. The user will enter his or her phone number in the input text box and, when the button is clicked, the swap function swaps the last 4 digits in the phone number with the first three.
<html> <body> <script language="JavaScript1.2"> <!–– Hide // function takes the input and swaps the last 4 digits with the // first three digits function swap(){ re = /(\w+)\D(\w+)/; str = document.form1.text1.value; newstr=str.replace(re, "$2, $1"); document.form1.text2.value ... |
Read now
Unlock full access