Daniel Rubio Daniel Rubio - 3 months ago 8
jQuery Question

jquery to find numbers with regular expressions not working

I have a script to find numbers with in the following format

(***)***-***

but it doesn't seem to be working. I tried finding phone numbers with only dashes and that worked but when adding the parenthesis doesn't seem to work

$(document).ready(function () {
$('body').html($('body').html().replace(/(\(\d\d\d\)-\d\d\d-\d\d\d\d)/g, '<span style="display:inline-block;">$1</span>'));
});

mmm mmm
Answer

If you want to find phone numbers like this (***)***-***, use

/\(\d{3}\)\d{3}-\d{3})/g