Home  >  Article  >  Backend Development  >  求秒个简单正则,

求秒个简单正则,

WBOY
WBOYOriginal
2016-06-23 14:03:08812browse

$a='aa,aa,';
$b=preg_replace('#[.*]+(,)#','',$a);
echo $b;


求结果aa,aa

不要trim()函数要正则。


回复讨论(解决方案)

$a='aa,aa,';
$b=preg_replace('#,$#','',$a);
echo $b;


是这意思?

$a='aa,aa,';
$b=preg_replace('#,$#','',$a);
echo $b;


是这意思?

哎 退步了就这么个意思!

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