I'm trying to figure out a way to parse a document for phone numbers (in several formats) so that it automatically wraps them in a span. Here's the code I threw together.
findPhones = function(){
var pNumber = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
var findPhone = $('*:contains('+pNumber+')');
findPhone.each(function(i) {
$(this).prepend('<span>');
alert('Phone Number Found, delete me');
$(this).append('</span>');
});
}
I have no idea how to check the entire document (or element for that matter) to see if it's a phone number.