Just thought I would post an update on this as I am working on this to match via jquery and automatically select the appropriate shipping carrier. I compiled a list of the matching regex for my project and I have tested a lot of tracking numbers across UPS FedEX and USPS.
If you come across something which doesn't match, please let me know here via comments and I will try to come up for that as well.
UPS:
/(1Z ?[0-9A-Z]{3} ?[0-9A-Z]{3} ?[0-9A-Z]{2} ?[0-9A-Z]{4} ?[0-9A-Z]{3} ?[0-9A-Z]|[dT]ddd ?dddd ?ddd)/
FedEX: (3 Different Ones)
/(96d{20})|(d{15})|(d{12})/
/((98ddddd?dddd|98dd) ?dddd ?dddd( ?ddd)?)/
/^[0-9]{15}$/
USPS: (4 Different Ones)
/(d{30})|(91d+)|(d{20})/
/^ED{1}d{9}D{2}$|^9d{15,21}$/
/^91[0-9]+$/
/^[A-Za-z]{2}[0-9]+US$/
Please note that I did not come up with these myself. I simply searched around and compiled the list from different sources, including some which may have been mentioned here.
Thanks
Edit: Fixed missing end delimiter.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…