<!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"> <!-- //alert(/^\d$/g.test( 'd11')); function ReplaceDemo(){ var r, re; // 声明变量。 var ss = "The rain in Spain falls mainly in the plain."; re = /(\S+)(\s+)(\S+)/g; // 创建正则表达式模式。 r = ss.replace(re, "$3$2$1"); // 交换每一对单词。 return(r); // 返回结果字符串。 } //alert(ReplaceDemo()); //alert('s abc dfdf'.replace(/\s*/g,'')); function RegExpTest(){ var ver = Number(ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion()) if (ver >= 5.5){ // 测试 JScript 的版本。 var src = "The rain in Spain falls mainly in the plain."; var re = /\w+/g; // 创建正则表达式模式。 var arr; while ((arr = re.exec(src)) != null) document.write(arr.index + "-" + arr.lastIndex + "\t" + arr); } else{ alert("请使用 JScript 的更新版本"); } } RegExpTest(); //--> </script> </body> </html>
js正则表达式 Regex
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
下一篇:js遍历选中的dom元素

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
正则表达式疑难释义-1
对正则表达式中的疑难与疑惑进行进一步解释说明
正则表达式 python -
python@regex正则表达式
函数时,模式作为第一个参数传递。如果在正则中使用捕获括号,则它们的值也将作为列表的一部分返回。除了你无法检索组
正则表达式 python 前端 字符串 正则