RegExp.compile() : RegExp Object : Regular Expressions JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Regular Expressions » RegExp Object »

 

RegExp.compile()












Syntax








regexp.compile(pattern, flag)



The compile() method of the RegExp object compiles a regular expression object.

The creation of the object takes pattern and flags parameters.

The pattern is a valid regular expression.

The flags are either or both g (global) and i (ignore case).












<html>
    <body>
    <script language="JavaScript">
    <!--
 
    var myPat = new RegExp("dd""i");
    var newPat = myPat.compile(myPat);

    function getinfo(){
        document.form1.text1.value = newPat;
    }
    -->
    </script>

    <form name="form1">
    Click the button below to get the pattern for the following
    command: new RegExp("dd""i");
    <br><br><br>
    Compiled Pattern: <input type="text" name="text1" size=30>
    <br><br>
    <input type="button" value="Get Pattern" onClick='getinfo()'>
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Regular Expressions
» RegExp Object