regular expression capture nth match

前端 未结 1 2012
小鲜肉
小鲜肉 2020-11-29 10:23

Is there any way to, using regular expression, return the nth occurrence? I did search the forums and only found solution that goes beyond regular expression itself (i.e. ne

相关标签:
1条回答
  • 2020-11-29 11:11

    for nth match use this pattern (?:.*?\$[0-9.]+){XX}.*?(\$[0-9.]+)
    where XX = n-1

    Example for 3rd match

    0 讨论(0)
提交回复
热议问题