Tuesday, March 1, 2011

Split a string at asterisk(*) character

In this case you have to escape the asterisk(*) character as below.
String s = "I*LOVE*JAVA";
String[] parts = s.split("\\*");
for (int i = 0; i < parts.length; i++) {
  System.out.println(parts[i]);
}

No comments:

Post a Comment