Answered by : mobile-star
String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556
Source : | Last Update : Sat, 08 Feb 20
Answered by : conrad-bhnke
// Split a string by whitespace
String input = "Hello World!";
String[] words = input.split("\\s+");
Source : | Last Update : Wed, 02 Aug 23
Answered by : n0rther
String yourString = "Hello/Test/World";
String[] strings = yourString.split("/" /*<- Regex */);
Output:
strings = [Hello, Test, World]
Source : | Last Update : Wed, 24 Jun 20
Answered by : oldfashioned-osprey-dsofpothed9u
function splitify(str) { // Add your code below this line return str.split(/\W/); // Add your code above this line
}
splitify("Hello World,I-am code");
Source : https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-split-a-string-into-an-array-using-the-split-method/18305 | Last Update : Fri, 20 May 22
Answered by : bewildered-buzzard-u8gl7vxy0y60
Java example to split a string
String str = "A-B-C-D";
String[] strArray = str.split("-");
System.out.println(Arrays.toString(strArray)); // [A, B, C, D]
Source : https://howtodoinjava.com/java/string/java-string-split-example/ | Last Update : Sun, 12 Dec 21
Answered by : courageous-camel-y4vfpr8cix55
String[] array = values.split("\\|", -1);
Source : https://stackoverflow.com/questions/14414582/java-split-string-to-array | Last Update : Tue, 10 Nov 20
Answered by : inna-kim
String str= "abcdef"; String[] array=str.split("(?<=\\G.{2})"); System.out.println(java.util.Arrays.toString(array));
Source : | Last Update : Mon, 11 Apr 22