Regex to extract information from string

vkana
Level 2
Regex to extract information from string

Hi all,

I have the following city names ending by "CEDEX [0-9]":

MONACO CEDEX 15
PARIS LA DEFENSE CEDEX
AJACCIO CEDEX 1
CLERMONT FERRAND CEDEX 1
PARIS LA DEFENSE CEDEX
MARSEILLE CEDEX 07
DIJON CEDEX
TOURS CEDEX 9

I would like to keep only city name

How can I use Regex in Dataiku to obtain this result?

The result must be:

MONACO
PARIS LA DEFENSE
AJACCIO
CLERMONT FERRAND
PARIS LA DEFENSE
MARSEILLE
DIJON
TOURS

Could anyone help me please?

Thank you so much


Operating system used: Windows

0 Kudos
2 Replies
MiguelangelC
Dataiker

Hi Vkana,

You can use the 'Extract with regular expression processor' in a Prepare recipe to get the desired values.

From your example, a valid regex would be: ^(.*?)\sCEDEX\s?\d*$

a.PNG

You can use online resources such as https://regex101.com/ if you want to further modify the regex to fit with your business requirements.

vkana
Level 2
Author

Good! Thank you so much.

0 Kudos