Regular Expression (\S+?) vs (\S+))
This question already has an answer here:
The first means match a single character that is a non-whitespace character, between one and unlimited times, as many times as possible, giving back as needed (greedy) .
The second means Match a single character that is a non-whitespace character, between one and unlimited times, as few times as possible, expanding as needed (lazy) .
The difference is greedy or lazy repetition. From the Regex Buddy help file:
A greedy quantifier will first try to repeat the token as many times as possible, and gradually give up matches as the engine backtracks to find an overall match. A lazy quantifier will first repeat the token as few times as required, and gradually expand the match as the engine backtracks through the regex to find an overall match.
The differences can be seen in the images below:
链接地址: http://www.djcxy.com/p/76904.html上一篇: 清晰的认识量化值