Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 2 of 2

Thread: Updated Tracking Number RegEx

  1. #1
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default Updated Tracking Number RegEx

    I've started this thread because I've found that the regex for determining which tracking number is for which shipping service is wrong.

    UPDATE: I've found that a lot more than just the regex is wrong. The code strips out spaces and dashes before trying a regex match. While this sounds good, FedEx freight numbers and DHL numbers are both 10 characters. Without the dash I can't tell which is which. When is really needed is a mod to the code to allow a picking of the carrier when the shipping tracking number is entered. This normally wouldn't be a problem because most people use the default carriers, but we have an option to use the account number with a carrier that the customer may have. In any case, it seems that using regex for the matching is a bad idea; it should be specifically keyed to the shipping method. I will update this post as I figure more of this problem out.

    For example, the regex for UPS is
    Code:
    ^(1Z)
    which clearly doesn't fit the description that UPS gives on their website (http://www.ups.com/content/us/en/tra...cking/tnh.html):

    Tracking numbers are used by UPS to identify and trace shipments as they move through the UPS system to their destination. UPS automatically assigns a tracking number to your shipment.

    UPS tracking numbers appear in the following formats:

    • 1Z9999999999999999
    • 999999999999
    • T9999999999
    • 999999999


    UPS will also track the following types of tracking numbers, which contain from seven to 20 characters:

    • Delivery Order/Sub-PRO Number: Less-Than-Truckload (LTL)/and Truckload (TL) child shipment tracking numbers
    • House Air Waybill: Used for air freight movement
    • House Bill of Lading: Used for ocean freight movement
    • PRO Number: Used for surface freight movement
    • UPS InfoNotice: A bar-coded notice, which includes a 12-digit reference number, given on first delivery attempt in select countries
    • UPS Service Notice: A notice given on first delivery attempt in select countries


    UPS Mail Innovations Tracking Numbers

    UPS Mail Innovations® uses tracking numbers to identify and track shipments as they move through the UPS Mail Innovations network and the United States Postal Service®, which makes the final delivery. With your tracking number, you can track your UPS Mail Innovations piece on both ups.com and upsmi.com. UPS Mail Innovations tracking numbers differ from a small package reference number in length and terminology.

    UPS Mail Innovations tracking numbers appear in the following formats:

    • United States Postal Service Delivery Confirmation Number: a 22-34 numerical identifier assigned by the U.S. Postal Service when Delivery Confirmation is requested
    • Sequence Number (MMS/MMI Number): an 18-digit number assigned internally by UPS Mail Innovations or UPS Worldship
    • Mail Innovations Compliant Package ID: a barcode-type identifier assigned by the shipper to each mail piece, using the structure below:


    MIXXXXXXNNNNNNNNNNNNNNNNNNNNNN

    This indicator is made up of the following three components:

    • MI - a UPS Mail Innovations indicator
    • XXXXXX - a unique 6-digit customer number assigned by UPS Mail Innovations
    • NNNNNNNNNNNNNNNNNNNNNN - a unique number, up to 22 characters, assigned by the shipper to identify a mail piece. Use alpha and/or numeric characters with no spaces or symbols. The same ID should not be reused for other mail pieces for at least six months.

    If anyone has updated tracking number regex code, please post it in this thread. I will try to keep all the best regex updated in the second post of this thread.
    Last edited by cjbarth; 03-07-2013 at 12:42 PM.
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM

  2. #2
    cjbarth is offline Senior Member
    Join Date
    Oct 2008
    Posts
    392

    Default

    UPS (http://www.ups.com/content/us/en/tra...cking/tnh.html):
    Default:
    Code:
    ^(1Z)
    Suggested:
    Code:
    ^(1Z\d{16})|(\d{12})|(T\d{10})|(\d{9})$
    AusPost:
    Default:
    Code:
    ^[0-9A-Z]{8}$
    Suggsted: DHL:
    Default:
    Code:
    ^\d{10,11}$
    Suggsted: FedEx:
    Default:
    Code:
    ^\d{12,19}$
    Suggsted: USPS (https://tools.usps.com/go/TrackConfi...n!input.action):
    Default:
    Code:
    ^\d{22}|[0-9A-Z]{11}US$
    Suggsted:
    Code:
    ^(7\d{19})|(\d{1}3\d{18})|(23\d{18})|((EA|EC|CP|RA)\d{9}US)|(82\d{8})$
    Last edited by cjbarth; 03-07-2013 at 11:20 AM.
    ML9.3.1.1
    SQL 2012 Express
    VS 2010
    Azure VM