Vaildating UPS tracking number

How to validate UPS tracking number, if user enters tracking number in a textbox ..is there a regex expression for validating UPS tracking number.
prasadrao007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
Can you describe the difference between a valid UPS tracking number and an invalid one?
0
b0lsc0ttIT ManagerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
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
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

b0lsc0ttIT ManagerCommented:
>> 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
prasadrao007Author Commented:
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
b0lsc0ttIT ManagerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.