【发布时间】:2014-11-17 04:37:45
【问题描述】:
嘿,我正在尝试将所选内容准确地放入数组中,但它不起作用。这是我得到的:
$stripped = "listing requirements. $ 669,647,431,200 P/E Ratio: 17.75 Forward P/E(1y) A widel";
$pattern = '/P\/E+\s+\w\w\w\w\w\W\s\w\w\W\w\w/';
preg_match($pattern, $subject, $matches);
print_r ($matches);
基本上我希望它只将“P/E Ratio: 17.75”输出到一个数组中。没有别的了。
我意识到如果市盈率是 114.13,我的表格也不起作用。我怎样才能让它选择接下来的两个“单词”?
谢谢!
【问题讨论】:
标签: php regex pattern-matching preg-match