Regular Expression to match most International phone numbers in US notation

So here’s a little RegEx I’ve whipped up that will match all of the following phone number notation styles:

^[\+]?[\d]{0,3}[\-|\s]?[\(]?[\d]{3}[\)|\-]?[\s|\d]?[\d]{2,3}[\-]?[\d]{3,4}$

EDIT: Fellow Google Pluser Bradley Moore took a crack at my expression above and cleaned it up a bit. Here’s the update:

^\+?\d{0,3}[ -]?\(?\d{3}\)?[ -]*\d{3}[ -]*\d{4}$

555-555-5555

555 555-5555

5555555555

15555555555

+15555555555

1-555-555-5555

+1-555-555-5555

+12 555-555-5555

+1 (555) 555-5555

(555) 555-5555

Cloning a JavaScript Object Using jQuery

I was recently using Keith Wood’s calendar plugin and kept running into an issue when trying to copy a date object and add days to it. When I would copy the object, I was actually just creating a reference to the original… Not what I wanted.

Found the answer was to clone the object, and John Resig had the answer via jQuery’s $.extend() method. It’s awesome when your fav lib has the method you need so writing one from scratch isn’t necessary. Check it out: Continue reading “Cloning a JavaScript Object Using jQuery”