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)
< TOTALLY UNTESTED BY ME AT THIS TIME >
*/
$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.
    hopy

  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
    friv

  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

  1. No trackbacks yet.