Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
328 views
in Technique[技术] by (71.8m points)

正则捕捉中(.*?)和(.*)的区别

Java使用正则匹配捕捉
1 Pattern p = Pattern.compile("name="sign" value="(.*)"/>");
2 Pattern p = Pattern.compile("name="sign" value=*"(.?)**"/>");
第二个比第一个多了一个?号,请问其中区别是什么


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

贪婪和非贪婪的区别。

简单来说,非贪婪是匹配到就停,不管后面还有没有,贪婪是只要后面还符合,就不会停。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...