skip to Main Content
<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


  1. have you solved it yet? I’m having a problem too

    Login or Signup to reply.
  2. There might be some issues with your Regex. Try debugging it, I checked via Regex101 and it showed errors.
    enter image description here

    Try reading this post How do you format a number to currency when using React native Expo?

    Hope this helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search