Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 匹配“#&引用;后面是数字“;使用正则表达式_Php_Regex_Expression_Preg Match_Preg Match All - Fatal编程技术网

Php 匹配“#&引用;后面是数字“;使用正则表达式

Php 匹配“#&引用;后面是数字“;使用正则表达式,php,regex,expression,preg-match,preg-match-all,Php,Regex,Expression,Preg Match,Preg Match All,我有一根绳子。并且需要得到“使用正则表达式”而不是分解而不是substr。。“123”或“345”后面的单词长度不同 String = "address number between #258 Kentucky"; 那样的话,去肯塔基州。我用过这个,但不起作用 \b#([0-9]+)\b 不能在非单词字符#之前使用\b(单词边界) 只需使用这个正则表达式: #([0-9]+)\s+(\w+)\b

我有一根绳子。并且需要得到“使用正则表达式”而不是分解而不是substr。。“123”或“345”后面的单词长度不同

String = "address number between #258 Kentucky";
那样的话,去肯塔基州。我用过这个,但不起作用

\b#([0-9]+)\b

不能在非单词字符
#
之前使用
\b
(单词边界)

只需使用这个正则表达式:

#([0-9]+)\s+(\w+)\b