user2251725 user2251725 - 1 year ago 70
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]);

Answer Source

You have to escape the brackets:

String REGEX = "\\[\\d+\\]";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download