What does ?: do in regex

前端 未结 3 1238
北荒
北荒 2021-01-01 11:05

I have a regex that looks like this

/^(?:\\w+\\s)*(\\w+)$*/

What is the ?:?

3条回答
  •  孤独总比滥情好
    2021-01-01 11:33

    Further to the excellent answers provided, its usefulness is also to simplify the code required to extract groups from the matched results. For example, your (\w+) group is known as group 1 without having to be concerned about any groups that appear before it. This may improve the maintainability of your code.

提交回复
热议问题