Richard Chan Richard Chan - 28 days ago 4x
Java Question

Simple way to remove all slashes at the end of url in java

I need to remove all slashed at the end of url,and i don't known how many slashes at the end.

for example

after removing slashe at the end

are there any simple ways like regular expression to do that.


use String.replaceAll ("\\/$", "");

The $ means that it is at the end of the String

As per @WiktorStribi┼╝ew to remove multiple slashes

use String.replaceAll ("/+$", "");