I have contact list and need to remove the country code(+91), spaces between number and zero(prefix with zero) from the mobile number. And it should contain only 10 digits.
I have tried using Regex in the following way, but it removing only spaces from the number.
var value = "+91 99 16 489165";
var mobile = '';
if (value.slice(0,1) == '+' || value.slice(0,1) == '0') {
mobile = value.replace(/[^a-zA-Z0-9+]/g, "");
} else {
mobile = value.replace(/[^a-zA-Z0-9]/g, "");
}
console.log(mobile);