1 var str="1 plus 2 equal 3"
2 
3 // 正则表达式
4 console.log(str.match(/\d+/g)); // ["1", "2", "3"]
5 console.log(str.match(/\d+/)); // ["1", index: 0, input: "1 plus 2 equal 3"]
6 
7 // 字符串
8 console.log(str.match(' ')); // [" ", index: 1, input: "1 plus 2 equal 3"]

【前端】String.prototype.match() 用法详解

 

相关文章:

  • 2022-12-23
  • 2021-07-23
  • 2022-01-29
  • 2021-11-01
  • 2021-12-29
  • 2022-02-13
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
相关资源
相似解决方案