im using react native TextInput for the phone number, the client want the phone number to look like NN NNN NN NN, found a solution to do spaces for each 3 numbers but that was not enough.
const handleCardNumber = (text) => {
let formattedText = text.split(' ').join('');
if (formattedText.length > 0) {
formattedText = formattedText.match(new RegExp('.{1,3}', 'g')).join(' ');
}
//this.setState({ cardNumber: text });
console.log(formattedText)
return formattedText;
}
this is the code i tried