<TextInput value={initialMoney}
onChangeText={(x) => {
setInitialMoney(x.replace(/B(?=(d{3})+(?!d))/g, '.'));
}}
/>
The above code will not work correctly.
Instead of displaying 214.124.124.124
It will display 2.1.4.1.2.4.1.2.4.123
There is nothing wrong with the Regular Expression, i tried the regex outside the TextInput and it works perfectly. Can anyone help me with this ?
2
Answers
have you solved it yet? I’m having a problem too
There might be some issues with your Regex. Try debugging it, I checked via Regex101 and it showed errors.
Try reading this post How do you format a number to currency when using React native Expo?
Hope this helps.