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

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

时间:2024-02-07 20:32:07浏览次数:25  
标签:Monday 无涯 names var RegExp prototype split

此方法根据指定的分隔符分割字符串对象,并返回字符串数组。

RegExp.prototype.split() - 语法

str.split([separator[, limit]])           
  • separator    -  可选。指定字符串的分隔符。

  • limit            -  可选。指定要找到的拆分数量的限制。

RegExp.prototype.split() - 返回值

返回在字符串中找到匹配项的索引。

RegExp.prototype.split() - 示例

var names='Monday;Tuesday;Wednesday';  
console.log(names);  
var re=/\s*;\s*/; 
var nameList=names.split(re);  
console.log(nameList);

运行上面代码输出

Monday;Tuesday;Wednesday 
Monday,Tuesday,Wednesday   

参考链接

https://www.learnfk.com/es6/es6-regexp-prototype-split.html

标签:Monday,无涯,names,var,RegExp,prototype,split
From: https://blog.51cto.com/u_14033984/9640243

相关文章

  • 无涯教程-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))......
  • 无涯教程-Math.asin(x)函数
    此函数返回x的反正弦。Math.asin(x)-语法Math.asin(x)x  - 代表数字Math.asin(x)-示例console.log("---Math.asin()---")console.log("Math.asin(0):"+Math.asin(0))console.log("Math.asin(Math.SQRT1_2):"+Math.asin(Math.SQRT1_2))......