最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Are there any Regex patterns that can determine a shipping company by an account number? - Stack Overflow

programmeradmin0浏览0评论

I am building a form wherein the user may enter a shipping account number. Primarily, I need to determine if the user has entered a valid pattern for a shipping account.

Secondarily, I would like to determine who the shipper is (e.g. UPS or FedEx). This would be similar to the way one can run a Regex against a credit card number to determine the card type (e.g. Visa, Amex, etc).

Please note that I am looking to validate account numbers and not tracking numbers.

Any help is appreciated.

In Summary:

  1. Primary Goal: a shallow validation for shipper Account Number, or a more definitive idea if it is even possible.
  2. Account Number differs from Tracking Number in that it is the customer identifier for the shipper used for billing purposes.
  3. Web searches/research result in numerous resources for Tracking Number, but nothing definitive about Account Number.
  4. Examples: None available due to the data being flagged sensitive internally, and web searches being inconclusive. I pare it to Credit Card Numbers: There shouldn't be any examples of valid numbers freely available. However, in the case of Credit Cards, the patterns are established enough that those can be located.
  5. Why I ask the munity? Just in case there is a pre-established RegEx that someone more experienced in this area might be familiar with.

I am building a form wherein the user may enter a shipping account number. Primarily, I need to determine if the user has entered a valid pattern for a shipping account.

Secondarily, I would like to determine who the shipper is (e.g. UPS or FedEx). This would be similar to the way one can run a Regex against a credit card number to determine the card type (e.g. Visa, Amex, etc).

Please note that I am looking to validate account numbers and not tracking numbers.

Any help is appreciated.

In Summary:

  1. Primary Goal: a shallow validation for shipper Account Number, or a more definitive idea if it is even possible.
  2. Account Number differs from Tracking Number in that it is the customer identifier for the shipper used for billing purposes.
  3. Web searches/research result in numerous resources for Tracking Number, but nothing definitive about Account Number.
  4. Examples: None available due to the data being flagged sensitive internally, and web searches being inconclusive. I pare it to Credit Card Numbers: There shouldn't be any examples of valid numbers freely available. However, in the case of Credit Cards, the patterns are established enough that those can be located.
  5. Why I ask the munity? Just in case there is a pre-established RegEx that someone more experienced in this area might be familiar with.
Share Improve this question edited May 27, 2014 at 16:02 kazebp asked May 23, 2014 at 17:42 kazebpkazebp 951 silver badge7 bronze badges 5
  • Any idea what account numbers may look like?? – Farhad Alizadeh Noori Commented May 23, 2014 at 17:45
  • So examples of patterns you'd like to match would be helpful. Have you made any attempts as yet? What went wrong? – David Thomas Commented May 23, 2014 at 17:46
  • Unfortunately, we don't have an example set to reference. So the problem I have is that I don't know what patterns to anticipate. I am wondering if these are standardized for different carriers in a way similar to the way credit cards have standard, recognizable patterns? – kazebp Commented May 23, 2014 at 17:47
  • I'm guessing you would have to figure out what to check for first then? Contact the shipping panies or try searching to see if you can figure out the format they use on their account # – adeneo Commented May 23, 2014 at 17:48
  • Thanks for the help, everyone~! I'll try to contact the panies when I'm off the clock. As for searching around, yes I tried that, but I've only encountered tracking number after tracking number. Account numbers could be considered sensitive, so I suspect people are less forthing regarding these. – kazebp Commented May 23, 2014 at 20:14
Add a ment  | 

2 Answers 2

Reset to default 4

There are RegEx patterns to validate the accounts if the shipper is known.
However, there are no RegEx patterns to determine the shipping pany since they are of similar length with no other pattern to uniquely identify.

RegEx patterns:

UPS Small Package account - 6 digits

\d{6}

UPS Freight account 8 - digits

\d{8}

UPS Air Freight account 9 - digits

\d{9}

FEDEX – 9 digits

\d{9}

DHL – 9 digits

\d{9}

References:

From email with UPS customer support:
UPS Small Package account: 6 digits
UPS Freight account: 8 digits

Search "What is a UPS Account Number?" yields:
UPS Account Number or Shipper Number: 6 digits
Air Freight Account Number: 9 digits

Search "What is a FedEx Account Number?" yields:
9-digit FedEx account number for FedEx QuickShip

Search "how many digits in a dhl account number" yields:
Clues to an initial pattern of "170", "95, 96".

Internal shipping department has verified the patterns they use:
FEDEX – 9 digits; UPS – 6 digits; DHL – 9 digits

Additional Research:
Email inquiries sent to UPS, FedEx, and DHL.
UPS has responded as indicated above.

After a quick digging in Google:

FedEx Express code (old) 12 digits:

\d{12}

FedEx Express code (new) 14 digits:

\d{14}

FedEx Ground code (old) 15 digits:

\d{15}

FedEx Ground code (new) 14 digits:

\d{14}

UPS code 1Z9999999999999999:

\d[A-Z]\d{16}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论