Question

RegEx help needed. Separate one attribute into four attributes


I'm new with FME. I have one attribute with this value "Zonne-energie in woonplaats vermogen 0,2394 MW, beschikte productie per jaar 227,43 MWh, looptijd 15 jaar. Het project is nog niet gerealiseerd (peildatum januari 2020)."

I want 4 values out of this values and put them into 4 attributes.

- 0,2394 MW into VERMOGEN

- 227,43 into PRODUCTIE

- 15 into LOOPTIJD

- januari 2020 into PEILDATUM

I want to use StringSearcher but i don't what Regular Expression to use. C

Who can help me?


5 replies

Userlevel 1
Badge +21

It would probably be helpful to provide some additional examples of your attribute values to enable queries to be formulated

Userlevel 2
Badge +16

I created a workspace for the 4 regular expressions.

Hope it helps.

regex.fmw

Userlevel 4

Making lots of assumptions here, but try the following four StringSearcher:

VERMOGEN

vermogen (\d*\,?\d+ \w+)

PRODUCTIE

productie per jaar ([[0-9]*[,]]?[0-9]+)

LOOPTIJD

looptijd (\d+)

PEILDATUM

peildatum (\w+ \d+)

All assume that the StringSearcher has been configured with a subexpression list name e.g. "_subs", the result will then be in "_subs{0}.part"

Userlevel 1
Badge +21

But for example:

VERMOGEN

a number followed by MW but not h

[0-9]*,*[0-9]* MW(?!h)

PRODUCTIE

a number followed by MWh but only return the number

[0-9]*,*[0-9]*(?=\sMWh)

LOOPTIJD

A numerical value followed by jaar

[0-9]*(?=\sjaar)

PEILDATUM 

Some letters and 4 numbers always preceded by peildatum

(?<=peildatum\s)[A-Za-z]+\s[0-9]{4}

Thank you all. It works!

Reply