java - regex replacing URL for image file extension; replace spaces with plus -
i learning regex , looking search url possible image extension (jpg, jpeg, png, gif .. etc) , if file extension of url image.
i want replace %20 or spaces plus signs +
how can done?
www.test.com/this/is/an/image&20with%20spaces.jpg www.test.com/this/is/an/image+with+spaces.jpg
you'll have in 2 lines, way see it.
pattern imagepattern = pattern.compile("\\.(png|gif|jpg|jpeg)$", pattern.case_insensitive); if (imagepattern.matcher(input).find()) input = input.replaceall("(%20)|\\s", "+");
Comments
Post a Comment