RegExp.$1,$2,..$9 : RegExp Object : Regular Expressions JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Regular Expressions » RegExp Object »

 

RegExp.$1,$2,..$9







The RegExp.$1,$2,..$9 property represents parenthesized substring matches.












<html>
    <body>
    <script language="JavaScript1.2">
    <!--

    function swap(){
        re = /(w+)D(w+)/;
        str = document.form1.text1.value;
        newstr=str.replace(re, "$2, $1");
        document.form1.text2.value = newstr;
    }
    -->
    </script>
    <form name="form1">
    Enter your digit phone number in the form xxx-xxxx
    <br><br><br>
    Phone Number (digits):<input type="text" name="text1" size=10>
    <br><br>
    <input type="button" value="Swap" onClick='swap()'>
    <br><br><br>
    Output: <input type="text" name="text2" size=10
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Regular Expressions
» RegExp Object