Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

How to split a string in Java

String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556
Comment

java split string

String yourString = "Hello/Test/World";
String[] strings = yourString.split("/" /*<- Regex */); 

Output:
strings = [Hello, Test, World]
Comment

java split string by length

String[] strings = "Thequickbrownfoxjumps".split("(?<=G.{4})"); // split all 4 chars
String[] strings = "Thequickbrownfoxjumps".split("(?<=G.{100})"); // this would be all 100 chars 
// -> ['Theq', 'uick', 'brow', 'nfox', 'jump', 's']
Comment

PREVIOUS NEXT
Code Example
Java :: how to generate random id in java 
Java :: java cast int to string 
Java :: android play sound file from assets 
Java :: replace substring at index java 
Java :: java numbers 
Java :: Who made java ? 
Java :: java zip file 
Java :: java jtable change column color 
Java :: containskey in java 
Java :: how to read file from console in java 
Java :: core java tutorial 
Java :: java download 64-bit 
Java :: reentrantlock java 
Java :: send whatsapp message java android studio 
Java :: 8.1.1. Declaring an Array&para; 
Java :: java for increment by 2 
Java :: initial data for list java 
Java :: java break 2 for loops 
Java :: milliseconds to seconds java 
Java :: navigate to another activity in android 
Java :: java get number out of string 
Java :: java create empty arraylist 
Java :: react The href attribute is required for an anchor to be keyboard 
Java :: java stack methods 
Java :: how to find the size of a queue in java 
Java :: java android edit text set value 
Java :: how to print byte array in java 
Java :: generating random number 
Java :: reverse in jaav 
Java :: string to int in java 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =