JavaStringsplit

Splits this string around matches of the given regex.

Syntax

str.split(regex, limit?)

Example

Enter values below to update the example in real time.

String
csv
parts
split
System
out
println
String csv = "apple,banana,cherry";
String[] parts = csv.split(",");
System.out.println(parts[0]); // "apple"
System.out.println(parts.length); // 3