Home > Backend Development > PHP Tutorial > 正则表达式求解,该如何处理

正则表达式求解,该如何处理

WBOY
Release: 2016-06-13 12:18:59
Original
903 people have browsed it

正则表达式求解
请问想匹配下面字符串的正则表达式该怎么写:
每个需要匹配的项目都是以空格结尾的

server_model=ProLiant DL360 G5;; server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz;; cpu=21mhz;1;3;5;8 



------解决思路----------------------

$s = "server_model=ProLiant DL360 G5;; server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz;; cpu=21mhz;1;3;5;8";<br />preg_match_all('/\s*(\S.+)(?:;;<br><font color='#FF8000'>------解决思路----------------------</font><br>$)/U', $s, $m);<br />print_r($m[1]);
Copy after login
Array<br />(<br />    [0] => server_model=ProLiant DL360 G5<br />    [1] => server_cpu_model=Intel(R) Xeon(R) CPU    E5405  @ 2.00GHz<br />    [2] => cpu=21mhz;1;3;5;8<br />)<br /><br />
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