title: best way to handle regex phone number in onChangeText react native
body: <p>I want to handle phone number field in <code>onChangeText</code> <code>TextInput</code> <code>React native</code>,</p>
  
  <p>from <a href="https://stackoverflow.com/a/14617994/8943429">this answer</a> i can use <code>^08[0-9]{9,}$</code> pattern, but the problem is on first number, regex wont allow 0 because of <code>08</code> on regex pattern, and if i add <code>0|08...</code>, regex allow 0 but it's allow any number on 2nd number instead of 08.</p>
  
  <p><strong>My Question :</strong>
  what is the best way to force regex handle first number is 0 and second number is 8? so i get 08xxxxxxxxxx (when x is another number 0-9)</p>
  
  <p>and here is an example of my current code in <code>reactJS</code>, you can feel i can type any number after i'm typing 0, and for new suggested regex <code>(^0|08[0-9]{9,}$)</code> i can't type any number anymore after 0,</p>
  
  <blockquote>
    <p>Notes: i don't know why my question marked as duplicate since the duplicated not help me to fix my issue</p>
  </blockquote>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class NameForm extends React.Component {
    constructor(props) {
      super(props);
      this.state = {value: ''};
  
      this.handleChange = this.handleChange.bind(this);
      this.handleSubmit = this.handleSubmit.bind(this);
    }
  
    handleChange(event) {
      let reg = /^0|08[0-9]{9,}$/
      if(reg.test(event.target.value)){
        this.setState({value: event.target.value});
      }
    }
  
    handleSubmit(event) {
      alert('A name was submitted: ' + this.state.value);
      event.preventDefault();
    }
  
    render() {
      return (
        &lt;form onSubmit={this.handleSubmit}&gt;
          &lt;label&gt;
            Phone:
            &lt;input type="text" value={this.state.value} onChange={this.handleChange} /&gt;
          &lt;/label&gt;
          &lt;input type="submit" value="Submit" /&gt;
        &lt;/form&gt;
      );
    }
  }
  
  ReactDOM.render(
    &lt;NameForm /&gt;,
    document.getElementById('root')
  );</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"&gt;&lt;/script&gt;
  
  &lt;div id="root"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>