javascript - How do I add white space in regex? -
i have code:
code js:
const phone= /^\(?(\d{3})\)?[-]?(\d{3})[-]?(\d{4})$/;
after running code has following form
(123)132-1312
i want add white space before last parentheses in example below.
(123 )132-1312
can please tell me how accept changes code white space?
thanks in advance!
edit:
text = $(this).val().replace(/(\d{3})(\d{3})(\d{4})/, "($1)$2-$3"); var testt=$(this).val().match(text);
i added code call here add white space ...
this should work need:
/^\(?\s*(\d{3})\s*\)?[-]?(\d{3})[-]?(\d{4})$/
Comments
Post a Comment