toString方法返回正则表达式的字符串表示形式。
RegExp.prototype.toString() - 语法
RegExpObject.toString();
RegExp.prototype.toString() - 返回值
返回正则表达式的字符串表示形式。
RegExp.prototype.toString() - 示例
var str="Javascript is an interesting scripting language"; var re=new RegExp( "script", "g" ); var result=re.toString(str); console.log("Test 1 - returned value : " + result); re=new RegExp( "/", "g" ); var result=re.toString(str); console.log("Test 2 - returned value : " + result)
运行上面代码输出
Test 1 - returned value : /script/g Test 2 - returned value : /\//g
参考链接
https://www.learnfk.com/es6/es6-regexp-prototype-tostring.html
标签:returned,无涯,toString,result,Test,RegExp,prototype From: https://blog.51cto.com/u_14033984/9640643