Divide a string into an array containing its constituent substrings.
String |
The split() method in Java divides a string into an array of substrings using a regular expression as the separator.
When a limit is defined, the resulting array won’t exceed this limit. The final element of the array holds the remaining portion of the string, which might include separators if the limit was reached.
Suggestion: Refer to the Java RegEx tutorial for a deeper understanding of regular expressions.
One of the following:
public |
public |
Parameter |
Description |
regex |
Necessary: a regular expression that specifies the separators at which the string will be divided. |
limit |
Optional: the maximum size of the resulting array. |
Returns: |
A string array. |
Throws: |
PatternSyntaxException occurs when the syntax of the regular expression is incorrect. |
Java Version: |
1.4 |