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

后端 未结 2 760
栀梦
栀梦 2021-02-07 00:57

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:25

    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

提交回复
热议问题