javaregexstringsplit

What does regular expression \\s*,\\s* do?


I am wondering what this line of code does to a url that is contained in a String called surl?

String[] stokens = surl.split("\\s*,\\s*");

Lets pretend this is the surl = "http://myipaddress:8080/Map/MapServer.html" What will stokens be?


Solution

  • That regex "\\s*,\\s*" means:

    which will split on commas and consume any spaces either side