What is the meaning of `?:` In the regular expression

I saw a regex to match the url: /^\/users?(?:\/(\d+)(?:\.\.(\d+))?)?/ . I am confused by the use of ?: At the beginning of each group match.

What is the meaning of this?

+7
source share
3 answers

(?:) ( () are part of the expression) is not an exciting group.

See http://www.regular-expressions.info/refadv.html .

+10
source

This is not an exciting group, so if a match is performed, this group will not be captured.

http://www.regular-expressions.info/refadv.html

+5
source

Read: http://docs.python.org/library/re.html

(?: ...)

Non-convertible version of regular parentheses. Matches any regular expression inside parentheses, but the substring matched by the group cannot be restored after matching or referencing later in the pattern.

+1
source

All Articles