PHP regex non-capture non-match group

前端 未结 3 927
天涯浪人
天涯浪人 2021-02-07 10:04

I\'m making a date matching regex, and it\'s all going pretty well, I\'ve got this so far:

\"/(?:[0-3])?[0-9]-(?:[0-1])?[0-9]-(?:20)[0-1][0-9]/\"
3条回答
  •  名媛妹妹
    2021-02-07 10:33

    1. It is a non capturing group. You can not back reference it. Usually used to declutter backreferences and/or increase performance.
    2. It means the previous capturing group is optional.

提交回复
热议问题