What does (?: do in a regular expression

后端 未结 4 1049
天涯浪人
天涯浪人 2021-02-02 09:57

I have come across a regular expression that I don\'t fully understand - can somebody help me in deciphering it:

^home(?:\\/|\\/index\\.asp)?(?:\\?.+)?$
<         


        
4条回答
  •  误落风尘
    2021-02-02 10:42

    It's a non-capture group, which essentially is the same as using (...), but the content isn't retained (not available as a back reference).

    If you're doing something like this: (abc)(?:123)(def) You'll get abc in $1 and def in $2, but 123 will only be matched.

提交回复
热议问题