JavaScript 字符串 string replace函数


JavaScript 字符串 string replace函数

<html>
   <head>
      <title>JavaScript String replace() Method</title>
   </head>

   <body>

      <script type = "text/javascript">
         var re = /apples/gi;
         var str = "Apples are round, and apples are juicy.";
         var newstr = str.replace(re, "oranges");

         document.write(newstr );
      </script>

   </body>
</html>