Global Matches using JavaScript Regular Expressions

前端 未结 2 1920
你的背包
你的背包 2021-01-27 20:55

Usually when you do something like \'test\'.match(/(e)/) you would receive an array [\'e\', \'e\'], where the first element is the match itself and the

2条回答
  •  迷失自我
    2021-01-27 21:45

    The behavior is specified at ECMA script language spec. This section describes in detail the procedure followed by the regex engine with and without the global modifier.

    Specific at point 11: If global is true, Call the [[Put]] internal method of R with arguments "lastIndex", e, and true.

提交回复
热议问题