0

guys! I've got a URL in which I want to encode every character but slashes "/". I've tried to use String.split() function, but it doesn't work as I'd like it to:

String url1 = "/images";
String url2 = "/images/";

url1.split("/"); // gives me {"", "images"}
url2.split("/"); // gives me the same array {"", "images"}, when I expect {"", "images", ""}

How can I get {"", "images", ""} array for string like "/images/" ? Maybe I need to use another regex?

Anatolii Stepaniuk
  • 2,585
  • 1
  • 18
  • 24

0 Answers0