Documentation for ?: in regex?

后端 未结 6 718
日久生厌
日久生厌 2020-12-08 14:36

A while ago, I saw in regex (at least in PHP) you can make a capturing group not capture by prepending ?:.

Example

$str = \'big blue b         


        
6条回答
  •  Happy的楠姐
    2020-12-08 15:00

    It's in the php manual, and I believe any other near-complete regular expression section for any language…

    The fact that plain parentheses fulfill two functions is not always helpful. There are often times when a grouping subpattern is required without a capturing requirement. If an opening parenthesis is followed by "?:", the subpattern does not do any capturing, and is not counted when computing the number of any subsequent capturing subpatterns.

    Source

提交回复
热议问题