Regular expressions (quantifier 2)

Greedy quantifier: preference match.

Ignore quantifiers: Priority choose to ignore.

Regular expression quantifier is greedy, that is, quantifiers will try to eat until the due eat too much, can not match the lead back, only to spit it out a.
For example, text ab1cd2, the regular expression. * [0-9] 
The matching process: * has been eating, found broken, digital can not match, so prominent 2, the match is successful, the end. That * matched ab1cd
If I want. * [0-9] matches ab1cd2 twice, how to do?
Ignore priority quantifier,. *? [0-9], plus quantifier behind a question mark. In other words, let * Try to eat less.
Matching process: * eat, eat not ah, A digital not match, then eat a, b numbers may not match, then eat the b, 1 matching digits ends. At the beginning of a match.

Escape:

* +? After the escape becomes / * / + /?

Guess you like

Origin www.cnblogs.com/lordwind/p/11498974.html