Home >Backend Development >PHP Tutorial >正则表达式匹配错误

正则表达式匹配错误

WBOY
WBOYOriginal
2016-06-06 20:22:181741browse

<code>preg_match("/^@\w+(#|:| ){1}$/", "content=#作曲家#看那你面的罢了:stuck_out_tongue_closed_eyes:@000000a ", $matches, PREG_OFFSET_CAPTURE);
</code>

我想匹配"@000000a",但结果不正确,希望懂的人可以指点一下,非常感谢!
content中的内容出现的顺序是随机的。

回复内容:

<code>preg_match("/^@\w+(#|:| ){1}$/", "content=#作曲家#看那你面的罢了:stuck_out_tongue_closed_eyes:@000000a ", $matches, PREG_OFFSET_CAPTURE);
</code>

我想匹配"@000000a",但结果不正确,希望懂的人可以指点一下,非常感谢!
content中的内容出现的顺序是随机的。

pregmatch(“/@(\w+)/”)

<code>preg_match("/@([0-9]+[A-Za-z]+)(#|:| )+$/", "content=#作曲家#看那你面的罢了:stuck_out_tongue_closed_eyes:@000000a#", $matches);
echo "<pre class="brush:php;toolbar:false">";
print_r($matches);
echo "
";

正则表达式匹配错误

/@\d+\w+/ 或者 /@[0-9]+[a-zA-Z]+/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn