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

后端 未结 2 835
猫巷女王i
猫巷女王i 2021-02-07 01:01

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*\");
<
2条回答
  •  面向向阳花
    2021-02-07 01:34

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

    • \s* any number of whitespace characters
    • a comma
    • \s* any number of whitespace characters

    which will split on commas and consume any spaces either side

提交回复
热议问题