title: Trouble with regex a value in javascript
body: <p>I am currently trying to mask an input field.I have the following code at the moment which formats the input:</p>
  <pre><code>    const inputMask = (value) =&gt; value.replace(/\s/g, '').match(/.{1,4}/g)?.join(' ').substr(0, 19) || '';
  
  </code></pre>
  <p>So i have an input field which calls the above function <code>inputMask</code> whenever a user is inputting a number.</p>
  <p>I have input XXXXXXXXXXX into the text input</p>
  <p>what gets returned is XXXX XXXX XXX from the inputMask function</p>
  <p>what i am trying to achieve is XXX-XXXX-XXXX</p>