Java split string explanation and example code
•
Java
Java split string
java. Split() method of lang. string, JDK 1.4 or later
public String[] split(String regex,int limit)
Sample code
Output results:
The split implementation directly calls the split method of the matcher class. When using string When the split method separates strings, if some special characters are used in the separator, we may not get the expected results. Characters with special meanings in regular expressions must be escaped when we use them, for example:
Split separator summary
1. The characters "|", "*", "+" must be preceded by the escape character "\ \".
2. If it is "\", it must be written as "\ \ \ \".
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码