Home  >  Article  >  Backend Development  >  PHP正则问题

PHP正则问题

WBOY
WBOYOriginal
2016-06-23 14:26:17895browse

求一个正则公式用来截取字符串:
比如在一段文本中我想获取这段文字(没有包括双引号):“截至2013-09-30,这是一些文字,这是一些文字。”
用正则如何写?我想匹配“截至2013-09-30 xxxxxxx 。”


回复讨论(解决方案)

xxxx 是指什么,具体匹配到哪

preg_match_all('~截至(.*?)。~');,找到开始和结束标记就好了。

xxxx 是指什么,具体匹配到哪

xxxx是省略 
比如“这是一段文字,,,,,,,截至2013-09-30,我站点击率达到100万次。这是一段文字。。。”我要取出 “截至2013-09-30,我站点击率达到100万次。”这段内容

$s='这是一段文字,,,,,,,截至2013-09-30,我站点击率达到100万次。这是一段文字。。。'preg_match('/截至(.+?)。/',$s,$m);echo $m[0];

$s='这是一段文字,,,,,,,截至2013-09-30,我站点击率达到100万次。这是一段文字。。。'preg_match('/截至(.+?)。/',$s,$m);echo $m[0];

非常感谢!

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