I have an existing regex:
/^http:\/\/twitter\.com\/(\w+)\/status(es)*\/(\d+)$/
that I use for determining if a URL is a twitter status update URL. Eg.
http://twitter.com/allWPthemes/status/2040410213974016
But ever since “new” twitter came out, they have changed the status URL’s to look like :
http://twitter.com/#!/allWPthemes/status/2040410213974016
with the added /#!
So my question is : How can I modify my regex to match both URL’s?
My final failed attempt was:
^http:\/\/twitter\.com\/(#!\/w+|\w+)\/status(es)*\/(\d+)$
Try this:
/^https?:\/\/twitter\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)$/This will match both the original URLs and the new hash tag URLs.
If you just want to match the new URLs, this should do it:
/^https?:\/\/twitter\.com\/#!\/(\w+)\/status(es)?\/(\d+)$/