这个正则表如何理解?
发表于 : 2007-05-05 22:28
/<img src="(.*?)"/m
===
我想应该是捕获网页的图片
<img src="
这样开始的行,但不明白后面的"(.*?)"/m
===
我想应该是捕获网页的图片
<img src="
这样开始的行,但不明白后面的"(.*?)"/m
代码: 全选
$ perldoc perlre
......
By default, a quantified subpattern is "greedy", that is, it will match as many times as possible (given a partic‐
ular starting location) while still allowing the rest of the pattern to match. If you want it to match the mini‐
mum number of times possible, follow the quantifier with a "?". Note that the meanings don’t change, just the
"greediness":
*? Match 0 or more times
+? Match 1 or more times
?? Match 0 or 1 time
{n}? Match exactly n times
{n,}? Match at least n times
{n,m}? Match at least n but not more than m times
......