我目前正在使用:
preg_match("/(.*)On\s+(Sun|Sat|Fri|Thu|Wed|Tue|Mon),\s+(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d?\d,\s+\d{4}\s+at\s+\d?\d:\d\d\s+[AP]M,/i", $to, $end);
它适用于:
$string = "I need to match this. On Sun, May 27, 2012 at 9:23 AM, Prov";
但不是为了:
$string = "I need to match this.
On Sun, May 27, 2012 at 9:23 AM, Prov";
$ string2中的返回不允许匹配。我可以在preg_match中更改某些内容,以便返回不会破坏我的结果吗?
答案 0 :(得分:7)
添加/s
修饰符以允许点(.
)也匹配换行符:
preg_match("/(.*)On\s+(Sun|Sat|Fri|Thu|Wed|Tue|Mon),\s+(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d?\d,\s+\d{4}\s+at\s+\d?\d:\d\d\s+[AP]M,/si", $to, $end);
答案 1 :(得分:0)
点'。'字符does not match换行符。