2022-09-30

REGEX expression for finding ship to address of different countries

I am trying to extract the shipping address from a commercial invoice.

One commercial invoice has ship to destination as Singapore. The other invoice has ship to destination as Hong Kong

How do I write a regex to extract the destination address, which ends either with Singapore or Hong Kong ?

I wrote a regex to extract the shipping address from a Commercial Invoice. see below:

shipto = re.findall("Shipped To/FRT Forwarder\n[a-zA-Z0-9\s\#\-\,]*SINGAPORE", text). 

My problem is the shipping address could be SINGAPORE or HONG KONG or another location. How can I make the regex more generic?

for example: my shipping address could be XXXX Singapore

or

YYYY Hong Kong

How do I implement a "either OR" logic in REGEX in the address extraction ?



No comments:

Post a Comment