Skip to main content

Still trying to sort this out.... I used the following expression to match all address formats in a field using the following expression:

 

IF REGEXP_MATCH([Replace],'(\d+[ ]([S|N|W|E][ ])?([0-9]+)?\w+[ ][ST|AVE|RD|PKWY|BLVD|PY|HWY|FWY|LN|CIR|CR|DR|PL|WAY|TR][ ])?')

THEN [Replace]

END

 

The expression appears to capture every format of address including: street number, optional street prefix (N, S, W, E), one or multi-part street name (digits with ordinal number abbreviations or just letters), optional street suffix (RD, AVE, ST, etc.), and optional unit number and/or letter.

 

However, what I want to do next is to extract all address info. except for unit numbers and/or letters when they occur. I've tried numerous iterations using REGEXP_REPLACE, or REGEXP_EXTRACT after matching, but can't seem to get what I want.

 

Am I barking up the wrong tree with REGEX, and if so, are there other functions I should use instead?

 

Thanks for any assistance you can provide!

 

Bill

1 risposta
  1. 30 dic 2021, 15:03

    Hi Bill,

    Your REGEX was close. Please try the below...

     

    Revised RegEx:

    REGEXP_EXTRACT([Address w-Unit or Apt or #],'(\d+[ ](?:[A-Za-z0-9.-]+[ ]?)+(?:Avenue|Lane|Road|Boulevard|Drive|Street|Ave|Dr|Rd|Blvd|Ln|St)\.?)')

    Which in my example of test addresses returns the following:

    Hi Bill,Your REGEX was close. Please try the below... Revised RegEx:REGEXP_EXTRACT([Address w-Unit or Apt or #],'(\d+[ ](?:[A-Za-z0-9.-]+[ ]?)+(? 

0/9000