What is the difference between split("\\s+") and split(" +")?

"hello world, this is Al".split("\\s+")



First of all, we must understand the meaning of the parameters of the split method:
split
public String[] split(String regex) Splits this string according to a match of the given regular expression.

Then we need to clarify the meaning of the regular expression:
\\s represents blank characters such as spaces, carriage returns, line feeds, etc.    
 The + sign means one or more, so...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324694339&siteId=291194637