How to get a string between two characters?

java, string

Solution

There's probably a really neat RegExp, but I'm noob in that area, so instead...

String s = "test string (67)";

s = s.substring(s.indexOf("(") + 1);
s = s.substring(0, s.indexOf(")"));

System.out.println(s);

Problem

I have a string, ``` String s = "test string (67)"; ``` I want to get the no 67 which is the string between ( and ). Can anyone please tell me how to do this?

Original source

Related problems