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

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

WBOY
Release: 2016-06-20 12:41:03
Original
1460 people have browsed it

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


回复讨论(解决方案)

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

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