我想從圖像URL字符串中刪除大小規範,但我似乎無法找到解決方案。我對正則表達式沒有太多的瞭解,所以我嘗試了[0-9x]
,但它只刪除了url中的所有數字,而不僅僅是維度子字符串。我只想擺脫如110x61
這樣的零件。Java的正則表達式 - 忽略圖像url中的大小字符串
我想我的琴絃從這個轉換:
http://techdissected.com/wp-content/uploads/2014/09/google-fiber-rabbit-11-110x61.jpg?6da9e4
http://techdissected.com/wp-content/uploads/2014/09/Nixeus-Headphones-Featured-Image-110x41.jpg?6da9e4
http://techdissected.com/wp-content/uploads/2014/03/Ampedlogo_rac15a_featured-110x94.jpg?6da9e4
這樣:
http://techdissected.com/wp-content/uploads/2014/09/google-fiber-rabbit-11.jpg?6da9e4
http://techdissected.com/wp-content/uploads/2014/09/Nixeus-Headphones-Featured-Image.jpg?6da9e4
http://techdissected.com/wp-content/uploads/2014/03/Ampedlogo_rac15a_featured.jpg?6da9e4
我使用RegexPlanet測試模式,但沒有什麼,我想出來的作品... 什麼正則表達式可以解決我的問題?任何幫助,將不勝感激。刪除尾部的加分?6da9e4
我找到了一個有趣的解決方案here,但它似乎在Java中不起作用。
連字符總是在子串之前嗎?即「-110x61」? – hwnd 2014-09-26 01:20:59
請參閱[demo](http://www.regexr.com/39iqt) – Baby 2014-09-26 01:26:42
@hwnd是的,子字符串前總是有一個連字符。 – Pkmmte 2014-09-26 23:44:10