未知修饰符';g';PHP正则表达式错误

未知修饰符';g';PHP正则表达式错误,php,regex,Php,Regex,我的模式是:/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g 和数据: 和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

我的模式是:
/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g
和数据:

和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];

}}
$regexp='/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/g';
如果(preg_match($regexp“,$input,$matches,preg_SET_ORDER)){

对于($i=0;$i切换到
preg\u match\u all
是正确的,现在只需从正则表达式中删除“g”:

$regexp = '/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/';

删除那个g,它就会工作

$regexp = '/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/';

没有G,它只返回第一个匹配的字符串!
-->0-->productimages/Routers/v/CISCO1941.jpg-->1-->productimages/-->2-->Routers-->3-->/v/-->4-->CISCO1941-->5-->.jpg-->6-->7-->8-->9-->10-->11-->12-->13-->我想要所有匹配的字符串!删除G只返回第一个匹配的字符串$matches[0][0]与您的问题无关,但您应该使用
\.
匹配点。
$regexp = '/(productimages\/)(\w*)(\/v\/)(\w*)(.jpg)/';