Richard Chan Richard Chan - 1 year ago 75
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.

Answer Source

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 ("/+$", "");

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download