我的模式是:/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g
和数据:http://gskinner.com/RegExr/?2ujor未知的修饰的 'g' PHP正则表达式错误
和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-匹配]:未知的修饰 '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-全匹配]:未知 修改 'G'
这个解决方案没有奏效! :| "Unknown modifier 'g' in..." when using preg_match in PHP?
我该怎么办?
完全无关的问题,但你应该使用'\ .'匹配点。 –