首页 > 其他分享 >无涯教程-RegExp.prototype.toString()函数

无涯教程-RegExp.prototype.toString()函数

时间:2024-02-07 21:31:39浏览次数:27  
标签:returned 无涯 toString result Test RegExp prototype

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

相关文章

  • 无涯教程-RegExp.prototype.split()函数
    此方法根据指定的分隔符分割字符串对象,并返回字符串数组。RegExp.prototype.split()-语法str.split([separator[,limit]])separator  - 可选。指定字符串的分隔符。limit      - 可选。指定要找到的拆分数量的限制。RegExp.prototype.sp......
  • 无涯教程-RegExp.prototype.match()函数
    此方法检索匹配项。RegExp.prototype.match()-语法str.match(regexp)Regexp  - 正则表达式对象。RegExp.prototype.match()-返回值返回一个匹配数组,如果找不到匹配项,则返回null。RegExp.prototype.match()-示例varstr='WelcometoES6.Weare......
  • 无涯教程-RegExp.prototype.test()函数
    test()方法在字符串中搜索与正则表达式匹配的文本。如果找到匹配项,则返回true;否则,它返回false。RegExp.prototype.test()-语法RegExpObject.test(string);string  - 要搜索的字符串。RegExp.prototype.test()-返回值如果找到匹配项,则返回匹配的文本,否......
  • 无涯教程-RegExp.prototype.exec()函数
    exec方法在字符串中搜索与正则表达式匹配的文本。如果找到匹配项,则返回输出数组。否则,返回null。RegExp.prototype.exec()-语法RegExpObject.exec(string);string  - 要搜索的字符串RegExp.prototype.exec()-返回值如果找到匹配项,则返回匹配的文本,否则......
  • 无涯教程-RegExp.prototype.sticky函数
    lastIndexRegExp对象的读/写属性。对于设置了"g"属性的正则表达式,它包含一个整数,该整数指定紧随RegExp.exec()和RegExp.test()方法找到的最后一个匹配项之后的字符位置,这些方法使用此属性作为它们进行下一次搜索的起点。RegExp.prototype.sticky-语法RegExpObject.lastInde......
  • 无涯教程-RegExp.prototype.multiline函数
    multiline是RegExp对象的只读布尔属性。它指定特定的正则表达式是否执行多行匹配,即是否使用"m"属性创建。RegExp.prototype.multiline-语法RegExpObject.multilineRegExp.prototype.multiline-返回值如果设置了"m"修饰符,则返回"TRUE",否则返回"FALSE"。RegE......
  • 无涯教程-RegExp.prototype.ignoreCase函数
    ignoreCase是RegExp对象的只读布尔属性。它指定特定的正则表达式是否执行不区分大小写的匹配,即是否使用"i"属性创建。RegExp.prototype.ignoreCase-语法RegExpObject.ignoreCaseRegExp.prototype.ignoreCase-返回值如果设置了"i"修饰符,则返回"TRUE",否则返回"......
  • 无涯教程-RegExp.prototype.global函数
    global是RegExp对象的只读布尔属性。它指定特定的正则表达式是否执行全局匹配,即是否使用"g"属性创建。RegExp.prototype.global-语法RegExpObject.globalRegExp.prototype.global-返回值如果设置了"g"修饰符,则返回"TRUE",否则返回"FALSE"。RegExp.prototype.......
  • 无涯教程-Math.atan2(y, x0)函数
    atan2方法介于-PI/2与PI/2弧度之间的数值来返回x的反正切值。Math.atan2-语法Math.atan2(x,y)x和y  - 代表一个数字Math.atan2-示例console.log("---Math.atan2()---")console.log("Math.atan2(0):"+Math.atan2(0,1))console.log("Math.atan2(M......
  • 无涯教程-Math.acos(x)函数
    此函数返回x的反余弦值。Math.acos(x)-语法Math.acos(x)x  - 代表数字Math.acos(x)-示例console.log("---Math.acos()---")console.log("Math.acos(0):"+Math.acos(0))console.log("Math.acos(Math.SQRT1_2):"+Math.acos(Math.SQRT1_2))......