Source Code:
(back to article)
Submit
Result:
Report an issue
import java.util.regex.Pattern; public class PatternDemo { private static String REGEX = ":"; private static String INPUT = "hello:dear:guest"; public static void main(String[] args) { Pattern pattern = Pattern.compile(REGEX); String[] result = pattern.split(INPUT); for(String data:result){ System.out.println(data); } } }