鉴于以下字符串如何使用PHP从字符串中删除子字符串?
http://thedude.com/05/simons-cat-and-frog-100x100.jpg
我想用substr
或trim
(或任何你找到更合适)返回此
http://thedude.com/05/simons-cat-and-frog.jpg
也就是说,除去-100x100
。我需要的所有图像都会在扩展名之前立即标记为文件名的末尾。
似乎有对此回应红宝石和Python,但不是PHP /特定于我的需要。
How to remove the left part of a string?
Remove n characters from a start of a string
Remove substring from the string
有什么建议?
你打算硬编码子字符串的值吗?或者你想匹配任何-WIDTHxHEIGHT.ext形式的子字符串? –
你介意链接到你找到的Ruby和Python版本吗?那里使用的技术可能是相关的。 – Ryan
@minitech - 在OP – pepe