PHP regular expression problem? ?

WBOY
Release: 2016-08-18 09:15:57
Original
1041 people have browsed it

<code class="php">$pattern = "/(abcd){1,2}.*(efgh){1,2}/";
$string = "abcd123efgh456";
preg_match_all($pattern,$string,$result);</code>
Copy after login
Copy after login

PHP regular expression problem? ?

I will write it like this. Put abcd and efgh into the result array. I hope to put abcd into the array instead of putting efgh into the array. How to write this pattern?


Thank you

Reply content:

<code class="php">$pattern = "/(abcd){1,2}.*(efgh){1,2}/";
$string = "abcd123efgh456";
preg_match_all($pattern,$string,$result);</code>
Copy after login
Copy after login

PHP regular expression problem? ?

I will write it like this. Put abcd and efgh into the result array. I hope to put abcd into the array instead of putting efgh into the array. How to write this pattern?


Thank you

(?:abcd)

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!