Help with Extracting Street Name, House Number, and Suffix from a Shipping Address

Hi everyone,

I’m trying to extract the street name, house number, and house number suffix from a WooCommerce shipping address field (e.g. Tweede Helmersstraat 43 II ) in a Set Variable module.

The format of the address can vary:

  • Some street names are 1 to 4 words long
  • House numbers may or may not have a suffix (e.g. 43, 43II, or 43-A)
  • The address is stored in 6.shipping.address1

I want to:

  1. Get everything before the first digit as the street name
  2. Get the digits as the house number
  3. Get anything after the digits as the suffix

I tried using indexOf() to find the first digit and then substring(), but I’m running into function errors, or pos = 999.

Has anyone successfully handled this type of address parsing in Make? A robust solution or function example would be greatly appreciated.

Thanks in advance!

Aymen

edit1: to retrieve the street name, I also tried this but received an empty output.

Hey Aymen,

something like this should do the match:

^(.*?)\s+(\d+)([-A-Za-z]*)$

You need to use the Match Pattern module though.

Many thanks for your reply!

I think i did like you said but get an empty output returned


Hi I’ve managed to get it working!

Many thanks Stoyan_Vatov!

I only had to add to Pattern \s* like this:

^(.*?)\s+(\d+)\s*([-A-Za-z]*)$

and had to add toString() to Text field

I can’t believe it works finaly haha, i’ve tried many different solutions for over 10 - 12 hours before coming here :laughing:

Cheers!

2 Likes