Home > Backend Development > PHP Tutorial > 一下一个正则表达式

一下一个正则表达式

WBOY
Release: 2016-06-13 12:09:38
Original
919 people have browsed it

求助一下一个正则表达式
需要匹配的字符串为:bbabbbbabc11
我想匹配到后面的abc11
用a(.+?)11的话, 会匹配到abbbbabc11

因为a和11中的字符不确定长度, 只想匹配最后的, 请问用一个正则的话, 有什么好办法。 
------解决思路----------------------

var str="bbabbbbabc11";<br /><br />var reg=/a[^a]*11/;<br /><br />alert(reg.exec(str));
Copy after login

------解决思路----------------------
$s = 'bbabbbbabc11';<br />$p = '/a[^a]+11/';<br />preg_match($p, $s, $m);<br />print_r($m);
Copy after login
Array<br />(<br />    [0] => abc11<br />)<br /><br />
Copy after login

Related labels:
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