Question: Dear friends I'reading a csv file that contains some file like this *1.086,12*. Now my problem is that I have to format it a way that allows my to create a BigDecimal, them my correct value should be 1086.12. But I could also have another value 99,11 and in this case I have to get 99.11.

I write this snippet of code:

```
BigDecimal bigDecimal = null;
String str = value.replace(',','.');
bigDecimal = new BigDecimal(str);

```

My code works just in the latter cese, Is there some regular expression that allows this?

Answer: 
You do not need a regex. You can/should use [DecimalFormat](http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html) for that:

```
    DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.GERMAN);
    DecimalFormat df= new DecimalFormat();
    df.setDecimalFormatSymbols(dfs);
    Double valCEWithUKFormat = df.parse(str).doubleValue();

```
You can use this Java code:

```
String[] arr = {"1.086,12", "99.11"};
for (String tok: arr) {
    if (tok.matches("[^.]*\\.[^,]+,.*"))
        tok= tok.replace(".", "").replace(",", ".");
    System.out.println( tok );
}

```

**output:**

```
1086.12
99.11

```