14 May String split(String regex) method in Java
The String[] split(String regex) method in Java splits this string around matches of the given regular expression.
Syntax
Let us see the syntax,
String[] split(String regex)
Parameters
Let us see the parameters,
- regex − delimiting regular expression
Example
The following is an example of String[] split(String regex),
public class StudyopediaDemo {
public static void main(String args[]) {
String message = new String("Study-opedia provides free learning content!");
System.out.println("String: "+message);
System.out.println("After split:");
for (String result: message.split("-")) {
System.out.println(result);
}
}
}
Output
The following is the output,

No Comments