日期:2014-05-17  浏览次数:20540 次

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);