EN
Java - split string by hyphen sign (minus sign - ascii 45 code)
3
points
In this article, we would like to show you how to split string by hyphen sign in Java.
Practical example:
public class Program {
public static void main(String[] args) {
String text = "some-example-text";
String[] parts = text.split("-");
System.out.println(parts[0]); // some
System.out.println(parts[1]); // example
System.out.println(parts[2]); // text
}
}
Output:
some
example
text