Skip to content Skip to sidebar Skip to footer

Hightlight Numbers In Phone Number

This function hightlight numbers. var hightlightPhoneNumbers = function(phoneNumber, hNumbers) { var splitPhoneNumber = phoneNumber.split(hNumbers); var result = ''; if (spl

Solution 1:

functionhightlightPhoneNumbers(phoneNumber, clip) {
    var re = newRegExp(clip.split('').join('[\\s-]*'), 'gi');
    return phoneNumber.replace(re, '<b>$&</b>');
}

By the way, there is this funny non-standard method of String.prototype.bold that wraps a string into a <b></b> tag.

Demo.

Post a Comment for "Hightlight Numbers In Phone Number"