当前位置:Gxlcms > PHP教程 > php正则,该如何处理

php正则,该如何处理

时间:2021-07-01 10:21:17 帮助过:3人阅读

php 正则
字符串如下:
height=450 type=application/x-shockwave-flash width=1000 src=http://max.flash34.com/u_90928/0cb4272311a2cfa5710e613e0600ae93.swf

写一个正则,获取height、src、width的值,有些有单引号的,有些双引号的,有些又没有,我的正则只能获取单引号和双引号的。如下:

preg_match_all('/(src|width|flashvars|height)=([\"|\'])?(.*?)(?(2)\2|\s)/is', $str, $matches);


------解决方案--------------------
咦。不是可以的么?
	
preg_match_all('/(src
------解决方案--------------------
width
------解决方案--------------------
flashvars
------解决方案--------------------
height)=(["\'])?([^\'" ]*)(?(2)\2)/i', $str, $matches);

人气教程排行