How to match multiple occurrences of a substring

后端 未结 3 790
逝去的感伤
逝去的感伤 2020-11-22 17:00

If I have an HTML string such as:

£2056

<
3条回答
  •  攒了一身酷
    2020-11-22 17:29

    Just allow the group to be repeated: (?:...)+ means "Match ... 1 or more times:

    str.match(/\d+(?:<[^>]*>)+\d+/)
    

    As per Alan Moore's suggestion, I've also changed the \d* into \d+, making the numbers required instead of optional.

提交回复
热议问题