What regex pattern would need I to pass to the java.lang.String.split()
method to split a String into an Array of substrings using all whitespace characters (' ', '\t', '\n', etc.) as delimiters?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
In most regex dialects there are a set of convenient character summaries you can use for this kind of thing - these are good ones to remember:
\w
- Matches any word character.\W
- Matches any nonword character.\s
- Matches any white-space character.\S
- Matches anything but white-space characters.\d
- Matches any digit.\D
- Matches anything except digits.A search for "Regex Cheatsheets" should reward you with a whole lot of useful summaries.
I'm surprised that nobody has mentioned String.split() with no parameters. Isn't that what it's made for? as in:
you can split a string by line break by using the following statement :
you can split a string by Whitespace by using the following statement :
"\\s+" should do the trick
Also you may have a UniCode non-breaking space xA0...