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. July 6th, 2015 at 03:53 | #1

    Thanks for sharing these info with us! this is a great site. I really like it. Thank you for the site. May God bless you in all your works

  2. July 13th, 2015 at 04:20 | #2

    Thanks for sharing these info with us!

  3. July 24th, 2015 at 06:57 | #3

    that website there had given me enough free gift cards and codes online.

  4. August 6th, 2015 at 23:27 | #4

    you can get this link here for codes and gift cards online here .

  5. sabir
    September 27th, 2015 at 06:28 | #5

    this webpage for free online facebook hacker ia a good one for facebook account online.

  6. brave
    September 27th, 2015 at 06:51 | #6

    GET the latest moviestarplanet hack tool that can give you vip membership online.

  7. kamal
    October 27th, 2015 at 22:28 | #7

    Your content and blog is awesome .i want to thank you keep it up! free itunes gift card codes

  8. Juegos Friv 7
    November 17th, 2015 at 03:36 | #8

    Many thanks for sharing Juegos Friv 7

Comment pages
1 2 322
  1. No trackbacks yet.