【发布时间】:2011-11-09 16:36:16
【问题描述】:
我的模式是:/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g
和数据:http://gskinner.com/RegExr/?2ujor
和php代码:
$regexp = ' /(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g';
if(preg_match("$regexp", $input, $matches, PREG_SET_ORDER)) {
for($i=0;$i<14;$i++){
echo '--->'.$i.'-->'.$matches[0][$i];
}}
结果:警告:preg_match() [function.preg-match]:未知修饰符 'g'
$regexp = ' /(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g';
if(preg_match_all("$regexp", $input, $matches, PREG_SET_ORDER)) {
for($i=0;$i<14;$i++){
echo '--->'.$i.'-->'.$matches[0][$i];
}}
结果:警告:preg_match_all() [function.preg-match-all]:未知 修饰符“g”
此解决方案无效! :| "Unknown modifier 'g' in..." when using preg_match in PHP?
我该怎么办?
【问题讨论】:
-
与你的问题无关,但你应该使用
\.来匹配一个点。