Skip to main content

Dear users,

 

I have a string attribute stored in a field for >150k point features including addresses, numbers, and sometimes additives.

 

Three examples of addresses:

 

Maria van Reedestraat 9-BS

Eduard Künnekehof 1

Bucheliusstraat 11-BS

 

What I would like to have, is a new attribute indicating only the street name (= everything before the last space) and a new attribute only having the street number plus additive, which matches everything after the last space.

 

I have found some tips regarding regular expressions, but I haven't found a way out yet.

 

Any help would be appreciated!

 

Thanks in advance,

 

Martin

A non-regex solution could be to use an AttributeSplitter with the space as separator character to create a list, then a ListElementCounter to count the number of elements in the list and a ListIndexer to grab the last item (_element_count - 1)

Schermafbeelding 2021-12-08 122300


You could try something like this in the string searcher, being sure to set the subexpression matches list name. It will match two groups, everything before the last space and everything after the last space

(.*)\s( ^\s]*$)

Then you can rename the first and second list elements as appropriate

image


A non-regex solution could be to use an AttributeSplitter with the space as separator character to create a list, then a ListElementCounter to count the number of elements in the list and a ListIndexer to grab the last item (_element_count - 1)

Schermafbeelding 2021-12-08 122300

Thank you very much! I just saw a pop up in my email, tried it, and it worked immedeately.

You're my hero of the day! :)


Alternatively, if you want to do it all in one transformer, in an AttributeCreator or AttributeManager

Get the streetname by replacing everything after the last space with nothing

@ReplaceRegEx(@Value(Input),\sl^\s]*$,"")

Get the number by replacing everything up until the last space with nothing

@ReplaceRegEx(@Value(Input),.*\s,"")

 


You could try something like this in the string searcher, being sure to set the subexpression matches list name. It will match two groups, everything before the last space and everything after the last space

(.*)\s( ^\s]*$)

Then you can rename the first and second list elements as appropriate

image

Dear ebygomm, tried your answer as well! You are also my hero of the day, since it works immediately.


Thank you very much! Both solutions work, so I'm very happy!


Reply