The pattern matching methods in the RegExp object require String objects. : Introduction : Regular Expressions JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Regular Expressions » Introduction »

 

The pattern matching methods in the RegExp object require String objects.








Pattern Matching Methods in the RegExp Object



















Method Description
exec(str) Searches for pattern in str and returns result
test(str) Searches for pattern in str and returns true if match found, otherwise false is returned
(str) Same as exec(str) method















<html>
<SCRIPT LANGUAGE='JavaScript'>
<!--
    var str = "A BC 5 DEF 135 Abc.<BR>"

    var span3to5 = new RegExp("[3-5]","g");
    document.write(str);
    document.write("Replace digits 3 to 5 with nines.<BR>");
    document.write(str.replace(span3to5,"9"));
    //-->
</SCRIPT>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Regular Expressions
» Introduction