Q:

How to delete certain characters from a string in certain locations?

I'm trying to take the a string and remove all the character from a char to another one
Example string:  
 String personAndPhone = " Dave (206515608)"

I want to convert this string into two strings, the person name and the phone number (without the "()").
How can I do it?

A:

Try this
String a[] = personAndPhone.trim().replaceAll("[()]", "").split(" ");

a[0] -> Dave
a[1] -> 206515608

A:

Use regex:
String name = str.replaceAll("\\s*(.*)\\s*\\(.*", "$1");
String phone = str.replaceAll(".*?\\((.*)\\).*","$1");

Both of these lines replace the entire input with group 1, which captures the target.
The "name" is everything up to the bracket, excluding whitespace at either end, so it would capture "John Smith 3rd" no problem.
The "phone" is everything between the first and last brackets, so it would capture "(01) 5678 9876" from " Dave ((01) 5678 9876) ".

