I built a calculator in ReactJs. And i would like to prevent the user from entering more than one decimal element eg `2..3` Anytime a user does this i'd like to replace all the decimal elements with a single one. So `2..3` would become `2.3`

This is how i am trying to achieve this but it doesnt work

```
if (calc.input.match(/\.{2,}/g)) {
  setCalc(calc.input.replace(/\.{2,}/g, "."));
}

```

`setCalc` is the hook i'm using to change state.