Q:

Java and regular expression, substring

I'm am tottaly lost when coming to regular expressions.
I get generated strings like: 
Your number is (123,456,789)

How can I filter out 123,456,789?

A:

You can use this regex for extracting the number including the commas 
\(([\d,]*)\)

The first captured group will have your match. Code will look like this
String subjectString = "Your number is (123,456,789)";
Pattern regex = Pattern.compile("\\(([\\d,]*)\\)");
Matcher regexMatcher = regex.matcher(subjectString);
if (regexMatcher.find()) {
    String resultString = regexMatcher.group(1);
    System.out.println(resultString);
}

Explanation of the regex
"\\(" +          // Match the character “(” literally
"(" +           // Match the regular expression below and capture its match into backreference number 1
   "[\\d,]" +       // Match a single character present in the list below
                      // A single digit 0..9
                      // The character “,”
      "*" +           // Between zero and unlimited times, as many times as possible, giving back as needed (greedy)
")" +
"\\)"            // Match the character “)” literally

This will get you started http://www.regular-expressions.info/reference.html 

A:

String str="Your number is (123,456,789)";
str = str.replaceAll(".*\\((.*)\\).*","$1");                    

or you can make the replacement a bit faster by doing:
str = str.replaceAll(".*\\(([\\d,]*)\\).*","$1");                    

