如何使用preg_match搜索变量$message
以查找文字[sh 2000]
变量$ message是从Web服务发送的。
我想知道[sh 2000]
是否已提交为[sh 2000]
所以我想忽略sh
和2000
之间存在空格。
数组[0]中的AND [PUT SH
和数组[1]中的#NUMBBER
;
之前([ONLYNUMBER] LIKE [2])我用过:
preg_match("/\[(\p{N}*)\]/", $message, $find)
任何帮助? 感谢
答案 0 :(得分:0)
$ php -r '$message = "[sh 2000]"; preg_match("/\[(\w+)\s*(\p{N}+)\]/", $message, $find); print_r($find);'
Array
(
[0] => [sh 2000]
[1] => sh
[2] => 2000
)
或:
$ php -r '$message = "[sh 2000]"; preg_match("/\[(\w+)\s*(\p{N}+)\]/", $message, $find); unset($find[0]); print_r($find);'
Array
(
[1] => sh
[2] => 2000
)