Combination of regular expressions of quantifiers *?

What does this combination of quantifiers mean *??

Use this as the following example:

([0-9][AB]*?)
+4
source share
2 answers

This is not a greedy match. In the [AB]*?regular expression, it searches for as few entries as possible [AB]so that the general match of the regular expressions matches the search string, while the greedy version [AB]*looks through as many cases as possible. This is a feature of Perl regexes and is therefore available in PCRE (Perl Compatible Regular Expressions) (see repetition ) and other systems that look at Perl to define them.

The PCRE page provides an example:

, [] , C. /* */, * /. C :

/\*.*\*/

/* first comment */  not comment  /* second comment */

, - .*.

, ,

/\*.*?\*/

C.

+5

, , , .

"9AB":

  • ([0-9][AB]*?) "9A", , "A" ()

  • ([0-9][AB]*) ( "9AB" ), "A" "B" ()

, , () "A" "B" s.

+2

All Articles