I have a price input like this:
<Input
keyboardType={"decimal-pad"}
inputStyle={{color: "#EDF5E1"}}
value={this.state.price.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.")}
onChangeText={(newPrice)=>this.setState({price: newPrice.toString().replace(".", ""})}
/>
My aim is to add dots to every 3 digits while the user is typing! like this(12.443.355)
this piece of code price.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.")}
works fine, but as user modifies the number, it messes up!
note that my problem differs from JavaScript; How to set dot after three digits?, I'm able to add dots, but it messes up when the user modifies it.