Home > Backend Development > PHP Tutorial > php 正则,该如何处理

php 正则,该如何处理

WBOY
Release: 2016-06-13 12:52:20
Original
1277 people have browsed it

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


------解决方案--------------------
咦。不是可以的么?
	<br />
    preg_match_all('/(src<br><font color='#FF8000'>------解决方案--------------------</font><br>width<br><font color='#FF8000'>------解决方案--------------------</font><br>flashvars<br><font color='#FF8000'>------解决方案--------------------</font><br>height)=(["\'])?([^\'" ]*)(?(2)\2)/i', $str, $matches);
Copy after login
 
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template