Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 仅使用正则表达式替换宽度大于300的_Php_Regex - Fatal编程技术网

Php 仅使用正则表达式替换宽度大于300的

Php 仅使用正则表达式替换宽度大于300的,php,regex,Php,Regex,我写了一些php代码,可以改变任何 width="any number" 用绳子 $width="300" 像这样: $width = 'width="300"' $content = preg_replace( '/width="([0-9]*)"/' , $width , $content ); 但是在这段代码中,所有的宽度都改变了,所以我希望它只替换超过300的宽度 那么我如何修改我的正则表达式来处理这个问题呢 谢谢 $content = preg_replace(

我写了一些php代码,可以改变任何

 width="any number"     
用绳子

 $width="300"  
像这样:

$width = 'width="300"'
$content = preg_replace( '/width="([0-9]*)"/' , $width , $content );
但是在这段代码中,所有的宽度都改变了,所以我希望它只替换超过300的宽度

那么我如何修改我的正则表达式来处理这个问题呢

谢谢

$content = preg_replace('/width="([3-9][0-9]{2,}|[1-9][0-9]{3,})"/',$width,$content);