Solved

Vaildating UPS tracking number

Posted on 2007-03-26
6
1,646 Views
Last Modified: 2008-01-09
How to validate UPS tracking number, if user enters tracking number in a textbox ..is there a regex expression for validating UPS tracking number.
0
Comment
Question by:prasadrao007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18798054
Can you describe the difference between a valid UPS tracking number and an invalid one?
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
ID: 18801736
UPS offers tools (I believe HTML or XML compatible) to validate the number.  It is part of their tools package.  They are available to customers or a developer.  Take a look at http://www.ups.com/content/us/en/tracking/tools/index.html.

Without details on what makes a valid number we would not be able to make an expression.  That information may be hard to find from UPS but they do have a summary at http://www.ups.com/content/us/en/tracking/help/tracking/tnh.html.  If you still want an expression, based just on the information there or information you provide, then let us know.  Let me know if you have a question about anything here.

bol
0
 
LVL 84

Expert Comment

by:ozo
ID: 18801874
assuming 9 means [0-9] and Z means [A-Z]
^(1[A-Z]\s*\d{3}\s*\d{3}\s*\d{2}\s*\d{4}\s*\d{3}\s*\d|\d{4}\s*\d{4}\s*\d{4}|T\d{3}\s*\d{4}\s*\d{3})$
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 18802030
>> assuming 9 means [0-9] and Z means [A-Z]

From my experience the 9 is 0-9 but the Z is just the letter Z (I don't know that for sure though).  I think the letter T is the same but it looks like the expression already got that.  I believe that would just be one minor change to the expression above (see below).  All credit to Ozo for the great expression which seems to check for the 3 common formats.

^(1Z\s*\d{3}\s*\d{3}\s*\d{2}\s*\d{4}\s*\d{3}\s*\d|\d{4}\s*\d{4}\s*\d{4}|T\d{3}\s*\d{4}\s*\d{3})$

bol
0
 

Author Comment

by:prasadrao007
ID: 19366232
sorry for not replying early ...i guess i didnt provide enough information in my question for validating UPS tracking number..thanks for the replies though..
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 19366305
Did you try the expressions we made up with the info available?  Did you still need help with this or have a question though?  I noticed the B grade and that seems a little odd since you never participated or asked for more help.  If there is something we can still help with then please let us know.  I will be happy to provide whatever help I can and you have some very good experts here to help with an expression.  It is nice to have a chance to earn the A.

Thanks for the fun question but the grade is puzzling and disappointing.

bol
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question