Home  >  Article  >  Backend Development  >  php正则捕获的有关问题

php正则捕获的有关问题

WBOY
WBOYOriginal
2016-06-13 10:34:57769browse

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);

Statement:
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