php正则捕获的有关问题

WBOY
Release: 2016-06-13 10:34:57
Original
775 people have browsed it

php正则捕获的问题


 
 

要把这里的Data Source=的内容,Initial Catalog=的内容,User ID=的内容,Password=的内容取出来,用正则怎么匹配?

preg_match("/Data Source=(\d+.\d+.\d+.\d+);.*Initial Catalog=(.*?);.*?;User ID=(.*?);Password=(.*?);.*/", $row['connectionString'], $matches);
上面是我的方法,但貌似有问题,新手求指教!

------解决方案--------------------
preg_match_all("/Data Source=([^;]+);.*?Initial Catalog=([^;]+);.*?User ID=(.*?);Password=(.*?);/s", $row['connectionString'], $matches);
print_r($matches);

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