Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串:
<div id="post_message_957119941">
我只想使用preg_match.
preg_match
这应该不会太难。
$str = '<div id="post_message_957119941">'; if ( preg_match ( '/post_message_([0-9]+)/', $str, $matches ) ) { print_r($matches); }
输出:
Array ( [0] => post_message_957119941 [1] => 957119941 )
所以想要的结果总是在:$matches[1]
$matches[1]
那是你需要的吗?