Link to home
Start Free TrialLog in
Avatar of prasadrao007
prasadrao007

asked on

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.
Avatar of ozo
ozo
Flag of United States of America image

Can you describe the difference between a valid UPS tracking number and an invalid one?
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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})$
>> 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
Avatar of prasadrao007
prasadrao007

ASKER

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..
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