Home  >  Article  >  Backend Development  >  求一个preg_replace替换字符串的前后缀的正则表达式

求一个preg_replace替换字符串的前后缀的正则表达式

WBOY
WBOYOriginal
2016-06-20 12:41:031441browse

如题,例如字符串 AUUUT,如何如掉开头的A与结尾的T,只剩下UUU
preg_replace('/^A.*T$/', '', 'AUUUT') 返回空


回复讨论(解决方案)

echo preg_replace('/^A|T$/', '', 'AUUUT');

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