title: Dollar Format Regex in React Native
body: <p>I'm trying to create a method in React Native that formats my input to dollar format.</p>
  
  <pre><code>onChangeNumberFormat = (text, input) =&gt; {
      const obj = { ...this.state.data };
  
      const value = text.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,')
      obj[input] = value;
  
      this.setState({
        data: obj
      });
    };
  </code></pre>
  
  <p>My input (I'm using Native Base):</p>
  
  <pre><code>&lt;Input
    value={Amount}
    onChangeText={(text) =&gt; this.onChangeNumberFormat(text, 'RentalAmount')}
    style={styles.valueText}
  /&gt;
  </code></pre>
  
  <p>When I enter 5000.00, it formats to 5,000.00 which is correct. However, if I delete the last 3 0 zeros, it becomes 5,00 instead of 500. How can I fix it? Also, is there a way to always put the '$' in the front and just accept numbers in the Input?</p>
  
  <p>Thanks</p>