求一行正则表达式,哪位能帮帮忙?

WBOY
Release: 2016-06-06 20:48:55
Original
1093 people have browsed it

求一行正则表达式,哪位能帮帮忙?

准备在这个软件里用

如果含有 “问答”、“百度”、"搜索" 这三个词当中的任意一个或几个,就把这几个词提取出来,并用逗号隔开

回复内容:

求一行正则表达式,哪位能帮帮忙?

准备在这个软件里用

如果含有 “问答”、“百度”、"搜索" 这三个词当中的任意一个或几个,就把这几个词提取出来,并用逗号隔开

<code class="lang-php"><?php preg_match_all('#(问答|百度|搜索)#ius','如果含有"问答"、"百度"、...',$matches);
print_r($matches[1]); //Array ( [0] => 问答 [1] => 百度 )
echo implode(',', $matches[1]); //问答,百度
</code>
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!