- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <title> New Document </title>
- <meta name="Generator" content="EditPlus">
- <meta name="Author" content="">
- <meta name="Keywords" content="">
- <meta name="Description" content="">
- </head>
- <body>
- <script type="text/javascript">
- var ss = "this is is my my first test test\n";
- var re = /\b([a-z]+) +\1\b/gim; //创建正则表达式样式.
- var rv = ss.replace(re,"$1"); //用一个单词替代两个单词.
- alert(rv);
- </script>
- </body>
- </html>
复制代码 |
|