Home > Computing, Programming, php > REGEX For common courier tracking numbers

REGEX For common courier tracking numbers

I was on the hunt not only to find the different variations each courier had for their tracking numbers but also a regex to match. Most of the google fu I found was outdated. Fedex “recently” (months? years? days?) changed from a 12 digit to 15 digit system. And NO, tracking numbers are not totally random. There is usually a space separation on the printed labels you see. Each of the spaced out subsets have a meaning to the courier as well as a checksum. Checksum being, a pre selected sequence of particular number positions added together then divided by a pre selected number. That you can search up yourself if you like. I didn’t find all too much on that matter either.

I am not very good with regex so if there are any suggestions by l33t coderz, they are more than welcome. On with the codes:

[ UPS ]
9 digits, or 1Z+whatever digits
The quick brown fox 1Z9999W99999999999 jumps over the lazy dog.
$ups = '/(\b\d{9}\b)|(\b1Z\d+\b)/';

[ Fedex ]
12 digits, 15 digits, or '96'+ 20 digits
The quick brown fox 999999999999 jumps over the lazy dog.
$fedex = '/(\b96\d{20}\b)|(\b\d{15}\b)|(\b\d{12}\b)/';

[ USPS ]
30 digits, '91'+20 digits, 20 digits (untested)
$usps = '/(\b\d{30}\b)|(\b91\d+\b)|(\b\d{20}\b)/';

I did get the common characters per courier from Packagetrackr. I don’t know how much of it is accurate, but from what I could tell from my experience with FedEx and UPS it seemed to be in line. I was unable to find an all inclusive source.

Categories: Computing, Programming, php Tags:
  1. November 7th, 2012 at 00:27 | #1

    If you don’t have to be responsible for own life, this is your own life a mistake! If you are not responsible
    for their own future, which is your own future a stomp! If you are not responsible for your happiness, which is your
    own happiness of a murder!

  2. March 6th, 2013 at 04:18 | #2

    This is a nice looking feature, but it seems to be broken for me. I attempted the import, I provided my yahoo credentials, I agree to allow access to yahoo and I am shown a list of my delicious bookmarks. When I click the ‘Import Checked Items’ an error is displayed. “an error occurred parseerror: undefined.

  3. janetmooredavidson
    June 19th, 2013 at 01:56 | #3

    This programming approach is quite complicated. Some are confused about the particular codes to be embedded or put in a particular place to run a program. This tutorial is informative and likewise a great help for programmers. – corporate video producer Orange CA

  4. July 13th, 2013 at 08:37 | #4

    Very informative post. Thanks for taking the time to share your view with us.

  5. November 18th, 2013 at 02:40 | #5

    it better than what I expected and all but bring your information is very interesting, thanks. kizi 4 | gazo 3

  6. grahamsam379
    December 2nd, 2013 at 08:16 | #6

    Cant comment something it is trickey and still informative post.. i try to understand.

    http://www.PMstudy.com/“>PMP training

  7. December 14th, 2013 at 05:10 | #7

    Sequence numbers show it I found it really hard to accomplish. I hardly care about it. Really thank you
    friv de friv

  8. February 26th, 2014 at 06:25 | #8

    This has a great future. You should starting your blog promotion through automation tool and engage more followers, The tool named vkonnect has a power to submit your blog content to social media.
    automatic social media posting

  9. March 10th, 2014 at 02:39 | #9

    I second the reaction to Keira Knightley and Orlando Bloom’s characters. Their stupid love story overshadowed what could have been a much more interesting plot.

  10. March 10th, 2014 at 02:40 | #10

    earaerg [url=http://rthrt.com]srthsrh[/url]

  11. March 27th, 2014 at 23:02 | #11

    Thank you for sharing this, who may also have been experiencing a few problems. But you helped them that.

  12. March 29th, 2014 at 06:09 | #12

    sharing for people to know a little about your work, I see you tried several and I support the work of your choice.

  13. April 21st, 2014 at 04:13 | #13

    I have been teaching a class and we are looking at this subject in the next week.

  14. May 18th, 2014 at 17:56 | #14

    So useful for me, thanks for sharing.

  15. June 3rd, 2014 at 01:53 | #15

    I’m happy with what is there

  16. June 22nd, 2014 at 10:22 | #16

    Thanks for sharing, this is a fantastic blog.Thanks Again. Great

  17. July 1st, 2014 at 21:37 | #17

    Studies show that green plants are good for workplaces where people perform creative tasks but bad where the work is more monotone.
    friv 2

  18. July 2nd, 2014 at 03:37 | #18

    You can write about the terms and conditions on the blog. You might chronicle it’s spectacular.

  19. July 12th, 2014 at 04:28 | #19

    I saw what you said is very good and it is very useful for me in life, thanks

  20. friv 3
    August 5th, 2014 at 21:16 | #20

    What’s even more comfortable when you are entertaining after a day of hard work.
    friv 3

  21. August 19th, 2014 at 08:05 | #21

    Such a nice blog thanks for share for increase my knowledge..

  22. August 26th, 2014 at 04:10 | #22

    hope you will share so much more to me more useful information and better, thanks.

  23. y9
    September 5th, 2014 at 03:10 | #23

    I love to read this type of material Good and attractive information I take from it..Thank you for posting such a good article. Y9

  24. September 21st, 2014 at 11:45 | #24

    I love your site because it has a lot of information and it helped me a lot and in my work. Thank you

  25. September 26th, 2014 at 03:00 | #25

    you always bring everyone the most interesting and useful, I like it all, thank you.

  26. October 1st, 2014 at 04:56 | #26

    Thank you for posting such a good article.

  27. yepi online
    October 14th, 2014 at 14:14 | #27

    The article you have shared here very awesome. I really like and appreciated your work. I read deeply your article, the points you have mentioned in this article are useful. I must try to follow these points and also share others. yepi online

  28. October 14th, 2014 at 21:34 | #28

    You can write about the terms and conditions on the blog. You might chronicle it’s spectacular.

  29. October 14th, 2014 at 22:13 | #29

    Your post was good and the information that you giving your post that was really cool. I like it very much. Thanks for posting this. Please share more information and I will bookmark to my blog

  30. October 28th, 2014 at 21:35 | #30

    Posts shared useful information and meaningful life, I’m glad to be reading this article and hope to soon learn the next article. thank you

  31. October 31st, 2014 at 21:39 | #31

    I’m happy with what is there So useful for me

  32. October 31st, 2014 at 22:09 | #32

    nice play ,nice post@ play baby hazel games

  33. October 31st, 2014 at 22:14 | #33

    play cool car games.

  34. October 31st, 2014 at 22:18 | #34

    I really like and appreciated your work. I’m glad to be reading this article and hope to soon learn the next article. thank you

  35. October 31st, 2014 at 22:20 | #35

    Thank you for sharing with us!I will pay attention to this topic in the future days.

  36. October 31st, 2014 at 22:24 | #36

    Nice post! I’ve learnt a lot from this post. I would like to share it with my friends

  37. December 2nd, 2014 at 02:45 | #37

    How many games have you been to this yearWe are wholesaler of Nike Jordan and Other Shoes in China.Free People Search EngineAfter a long search for old school friends, I kept finding search engine websites.

  38. December 25th, 2014 at 22:54 | #38

    Really great post, dear!
    Have an amazing day!

  39. February 6th, 2015 at 04:12 | #39

    Good post. I love!

  40. February 7th, 2015 at 03:09 | #40

    This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more … good luck.

  1. No trackbacks yet.