Home > Backend Development > PHP Tutorial > 求一段容易的正则表达式

求一段容易的正则表达式

WBOY
Release: 2016-06-13 12:54:42
Original
1002 people have browsed it

求一段简单的正则表达式
/file/upload/201212/24/18-51-40-65-61.jpg.thumb.jpg
/file/upload/201212/24/18-51-40-65-61.jpg.thumb.png
/file/upload/201212/24/18-51-40-65-61.jpg.thumb.gif
                 ..........

上面是文件名,我现在要把上面这种文件名用正则成下面这种形式
/file/upload/201212/24/18-51-40-65-61.jpg
/file/upload/201212/24/18-51-40-65-61.jpg
/file/upload/201212/24/18-51-40-65-61.jpg



就是把像下面这个替换成空。
.thumb.jpg
.thumb.png
.thumb.gif


------解决方案--------------------
$s=<<<html<br />
/file/upload/201212/24/18-51-40-65-61.jpg.thumb.jpg<br />
/file/upload/201212/24/18-51-40-65-61.jpg.thumb.png<br />
/file/upload/201212/24/18-51-40-65-61.jpg.thumb.gif<br />
html;<br />
echo preg_replace('/\.thumb\..+$/m','',$s);
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