Home > Backend Development > PHP Tutorial > 再问个正则表达式,关于结尾的$

再问个正则表达式,关于结尾的$

WBOY
Release: 2016-06-23 14:04:10
Original
1044 people have browsed it

preg_match_all ("/ar$/i","batr bar car ar asdf",$out);print_r($out);
Copy after login


这段代码有个$,不是应该以r结尾的单词吗  btar bar car ar 应该全部输出来吧。为什么什么都没有。
难道不是这样理解的吗


回复讨论(解决方案)

是检测这个串是否已ar结尾的。

preg_match_all ("/ar\b/i","batr bar car ar asdf",$out);

$是行尾...

$
断言目标的结尾(或在多行模式下行的结尾,即紧随一换行符之前)

你要的单词结尾2楼给你答案了,单词结尾的断言是\b。

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template