user2251725 user2251725 - 8 months ago 44
Java Question

How split a string using regex pattern

How split a [0] like words from string using regex pattern.0 can replace any integer number.
I used regex pattern,

private static final String REGEX = "[\\d]";

But it returns string with [.

Spliting Code

Pattern p=Pattern.compile(REGEX);
String items[] = p.split(lure_value_save[0]);


You have to escape the brackets:

String REGEX = "\\[\\d+\\]";