帮忙写个正则匹配,很简单解决思路

WBOY
Release: 2016-06-13 11:58:08
Original
736 people have browsed it

帮忙写个正则匹配,很简单
以下是该字符串可能出现的内容
$string ="【灵儿】返现70元";
$string ="前面可能有文字【灵儿】返现70元";
$string ="中间可能是中括号[灵儿]返现70元";

现在需要用正则匹配下,【】或者[]中的内容。
------解决方案--------------------

$string =<<< TXT<br />【灵儿】返现70元";<br />前面可能有文字【灵儿】返现70元<br />中间可能是中括号[灵儿]返现70元<br />TXT;<br />preg_match_all('/(\[<br><font color='#FF8000'>------解决方案--------------------</font><br>【)(.+?)(\]<br><font color='#FF8000'>------解决方案--------------------</font><br>】)/s', $string, $m);<br />print_r($m[2]);
Copy after login

Array
(
    [0] => 灵儿
    [1] => 灵儿
    [2] => 灵儿
)

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!