source是RegExp对象的只读字符串属性, 它包含RegExp模式的文本。
RegExpObject.source
返回用于模式匹配的文本。
<html> <head> <title>JavaScript RegExp source Property</title> </head> <body> <script type="text/javascript"> var str="Javascript is an interesting scripting language"; var re=new RegExp( "script", "g" ); re.test(str); document.write("The regular expression is : " + re.source); </script> </body> </html>
运行上面代码输出
链接:https://www.learnfk.comhttps://www.learnfk.com/javascript/regexp-source.html
来源:LearnFk无涯教程网
The regular expression is : script
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)