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?
A Quick Guide to Using split() This function can be used to split strings between characters. The split() function takes two parameters. The first is called the separator and it determines which character is used to split the string. The split() function returns a list of substrings from the original string.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With