search

Home  >  Q&A  >  body text

为什么声明匹配文本的第一个字符的位置是从0开始,而文本字符串却是从一开始,不是自相矛盾吗?

var reg4=/\d(\w)(\w)\d/g;
var ts ='$1az2bbc3y4dd5ee';

 var ret=reg4.exec(ts)


一辆想出轨的无轨电车一辆想出轨的无轨电车2899 days ago909

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:30:14

    Why is it stated that the position of the first character of matching text starts from 0, while the position of the text string starts from one? Isn’t it contradictory? -PHP Chinese website Q&A-Why is it stated that the position of the first character of matching text starts from 0, but the text string starts from the beginning? Isn't it contradictory? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 巴扎黑

    巴扎黑2016-12-21 17:26:32

    位置0是在第一个字符的前面,0之前没有字符,位置1前面的就是第一个字符

    reply
    0
  • Cancelreply