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


JAVASCRIPT TUTORIALS » Regular Expressions » RegExp Object »

 

RegExp.exec()











Syntax








regexp.exec(string)



The exec() method of the RegExp object executes the search for a match in a specified string.

The results are returned in an array.

The string passed contains the string the regular expression is trying to match in.












<html>
    <body>
    <script language="JavaScript">
    <!--
    myRe=/xyz*/g;

    str = "abcxyzdefhij"
    myArray = myRe.exec(str);
    document.writeln("Found " + myArray[0" in the pattern: " "<b>" "abcxyzdefhij " "</b>" " at index " (myRe.lastIndex - 3));
    -->
    </script>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Regular Expressions
» RegExp Object