Guest User

Untitled

a guest
Jan 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. phoneStr= '12345678912346';
  2.  
  3. phoneStr.replace(/(d{3})(d{3})(d{4})(d{3})/, '($1) - $2 - $3 Ext - $4');
  4.  
  5. let phoneStr= '12345678912346';
  6. let formatted = '(' + phoneStr.slice(0,3) + ') - ' + phoneStr.slice(3,6) + ' - ' + phoneStr.slice(6,10) + ' Ext - ' + phoneStr.slice(10,15);
  7. console.log(formatted);
Add Comment
Please, Sign In to add comment