我有一个字符串(来自文件):
ILX (New for 2013!)
Overview: The least expensive route to Honda's premium-label goodness
Drivetrain: Two four-cylinder engines to choose from as well as a gas-electric hybrid; front-wheel-drive only.
如何获取字符串:
$writeup = file_get_contents($car_files_path . $manufacture . '/Stories/'.$story);
我想匹配概述行 (Overview: The least expensive route to Honda's premium-label goodness)
。怎样才能最好地实现这一点?
我尝试过 .*\n
,但是会匹配到所有东西再加上一个新行。有没有办法让正则表达式不贪婪?
我尝试了:preg_match('/^Overview:\s.*$/im', $writeup, $overall_matches)
,但是没有匹配到任何结果。
.*?
。详情请参考:http://www.regular-expressions.info/repeat.html。 - Michael Berkowski