I am wondering what this line of code does to a url that is contained in a String called surl?
我想知道这行代码对名为surl的字符串中包含的url做了什么?
String[] stokens = surl.split("\\s*,\\s*");
Lets pretend this is the surl = "http://myipaddress:8080/Map/MapServer.html" What will stokens be?
让我们假装这是surl =“http:// myipaddress:8080 / Map / MapServer.html”会是什么?
2 个解决方案
#1
17
That regex "\\s*,\\s*"
means:
正则表达式“\\ s *,\\ s *”表示:
-
\s*
any number of whitespace characters - \ s *任意数量的空白字符
- a comma
- 一个逗号
-
\s*
any number of whitespace characters - \ s *任意数量的空白字符
which will split on commas and consume any spaces either side
它将在逗号上分开并消耗任何一侧的空格
#2
4
- \s stands for "whitespace character".
- \ s代表“空白字符”。
-
It includes [ \t\r\n\f]. That is: \s matches a space, a tab, a line break, or a form feed.
它包括[\ t \ r \ n \ f]。即:\ s匹配空格,制表符,换行符或换页符。
\s*,\s*
\ S * \ S *
\s* - says zero or more occurrence of whitespace characters, followed by a comma and then followed by zero or more occurrence of whitespace characters.
\ s * - 表示空白字符出现零次或多次,后跟逗号,然后出现零次或多次空格字符。
These are called short hand expressions.
这些被称为短手表达。
You can find similar regex in this site : http://www.regular-expressions.info/shorthand.html
你可以在这个网站找到类似的正则表达式:http://www.regular-expressions.info/shorthand.html
#1
17
That regex "\\s*,\\s*"
means:
正则表达式“\\ s *,\\ s *”表示:
-
\s*
any number of whitespace characters - \ s *任意数量的空白字符
- a comma
- 一个逗号
-
\s*
any number of whitespace characters - \ s *任意数量的空白字符
which will split on commas and consume any spaces either side
它将在逗号上分开并消耗任何一侧的空格
#2
4
- \s stands for "whitespace character".
- \ s代表“空白字符”。
-
It includes [ \t\r\n\f]. That is: \s matches a space, a tab, a line break, or a form feed.
它包括[\ t \ r \ n \ f]。即:\ s匹配空格,制表符,换行符或换页符。
\s*,\s*
\ S * \ S *
\s* - says zero or more occurrence of whitespace characters, followed by a comma and then followed by zero or more occurrence of whitespace characters.
\ s * - 表示空白字符出现零次或多次,后跟逗号,然后出现零次或多次空格字符。
These are called short hand expressions.
这些被称为短手表达。
You can find similar regex in this site : http://www.regular-expressions.info/shorthand.html
你可以在这个网站找到类似的正则表达式:http://www.regular-expressions.info/shorthand.html