JavaScript 正则表达式RegExp的toString方法


JavaScript 正则表达式RegExp的toString方法

<html>

   <head>
      <title>JavaScript RegExp toString Method</title>
   </head>

   <body>

      <script type = "text/javascript">
         var str = "Javascript is an interesting scripting language";
         var re = new RegExp( "script", "g" );

         var result = re.toString(str);
         document.write("Test 1 - returned value : " +  result);

         re = new RegExp( "/", "g" );

         var result = re.toString(str);
         document.write("<br />Test 2 - returned value : " +  result);
      </script>

   </body>
</html>