Question: What is the regex for these cases:

**29000.12345678900**, expected result **29000.123456789**

**29000.000**, expected result **29000**

**29000.00003400**, expected result **29000.000034**

In short, I want to eliminate the 0 point if there is no 1-9 found again behind decimal and I also want to eliminate the dot (.) if actually the number can be considered as integer.

I use this regex

```
(?:.0*$|0*$)

```

but it gives me this result:

**29123.6** from **29123.6400**, 4 is gone from there.

When I tested the regex separately, it works perfectly, 

`.0*$` gives me **29123** from **29123.0000**

`0*$` gives me **29123.6423** from **29123.642300**

Am I missing something with the combined regex?

Answer: 
If you think regex is the best way of doing it, you can just use something like this:

```
\.?0+$

```

It works for both cases:

```
> '12300000.000001130000000'.replace(/\.?0+$/g, '')
"12300000.00000113"
> '12300000.000000000000'.replace(/\.?0+$/g, '')
"12300000"

```
You can use this regex

```
^\d+(\.\d*[1-9])?
-   -------------
|        |->this would match only if the digits after . end with [1-9] 
|
|->^ depicts the start of the string..it is necessary to match the pattern

```

that solves your problem

try it [here](http://regexhero.net/tester/)