This function hightlight numbers.
var hightlightPhoneNumbers = function(phoneNumber, hNumbers) {
var splitPhoneNumber = phoneNumber.split(hNumbers);
var result = '';
if (splitPhoneNumber.length > 1) {
for (var i = 0; i < splitPhoneNumber.length - 1; i++) {
result += splitPhoneNumber[i] + '<b>' + hNumbers + '</b>';
}
return result + splitPhoneNumber[splitPhoneNumber.length - 1];
}
return phoneNumber;
};
And we can usage it as hightlightPhoneNumbers('+123456789','123')
.
But we have a little problem. What if phone number looks like +1 234-567-89? Ofcourse function doesnt work correct. How we can to fix it?
Hightlight means wrap numbers in tags or something. see http://jsfiddle.net/QhJWt/3/