Skip to main content

I want to perform a Regex search in a string and I want to pass the regex pattern via a feature attribute. However, when I pass the regex pattern in the attribute and select it in the StringSearcher in the field "Contains Regular Expression", I get no match. When I enter the pattern manually in this field, the matching works.

How can I pass a regex pattern via an attribute?

Seems to work just fine with FME 2019.1:

My regex contains "\\d+" and as a result _first_match contains "123", as expected.

Can you perhaps post a minimal workspace that reproduces the issue.


Ok...

My pattern looks like this:

0684Q00000ArJvuQAF.png

It has Umlaute (ä/ö/ü).

(EGRID)|(Gemeinde)|(Gebäudename)|(Gebäudeklasse)|(Objektname)|(Name des Gebäudes)|(Parzellennummer)

 

This is my StringSearcher.

0684Q00000ArKGiQAN.png

 

I use FME 2018.1


Ok...

My pattern looks like this:

0684Q00000ArJvuQAF.png

It has Umlaute (ä/ö/ü).

(EGRID)|(Gemeinde)|(Gebäudename)|(Gebäudeklasse)|(Objektname)|(Name des Gebäudes)|(Parzellennummer)

 

This is my StringSearcher.

0684Q00000ArKGiQAN.png

 

I use FME 2018.1

Does your text come line-by-line, or as a single block?


Does your text come line-by-line, or as a single block?

How can I determine this?


How can I determine this?

To ask differently, how many input features to the StringSearcher is there? A single one, or one input feature for each line of the text?

A sample workspace with sample values would be very helpful, so far I've been unable to find anything patently wrong with the StringSearcher in FME 2018.1, using your sample regex and text.


To ask differently, how many input features to the StringSearcher is there? A single one, or one input feature for each line of the text?

A sample workspace with sample values would be very helpful, so far I've been unable to find anything patently wrong with the StringSearcher in FME 2018.1, using your sample regex and text.

Ok, here it is: regex_pattern.fmw

Thanks a lot for your help!


You need to add the regex to your feature, at the moment it is on a separate feature, the attributecreator needs to be added inline before the stringsearcher


Ok, here it is: regex_pattern.fmw

Thanks a lot for your help!

You need to add the regex to your feature, at the moment it is on a separate feature, the attributecreator needs to be added inline before the stringsearcher


You need to add the regex to your feature, at the moment it is on a separate feature, the attributecreator needs to be added inline before the stringsearcher

Ah ok!

In the real workspace, this is not possible because the pattern is coming from a DB. I used a Feature Merger with 1:1 matching to get it in one feature.

Thanks again for your help!


You need to add the regex to your feature, at the moment it is on a separate feature, the attributecreator needs to be added inline before the stringsearcher

Or it is possible to use a Feature Merger with 1:1 to merge two streams.


Or it is possible to use a Feature Merger with 1:1 to merge two streams.

Yes, you can merge like that. If your pattern is coming from a database, i would add an inspector to the database reader and see what the pattern looks like. It may be an issue with the encoding.


Yes, you can merge like that. If your pattern is coming from a database, i would add an inspector to the database reader and see what the pattern looks like. It may be an issue with the encoding.

Ok, thanks. In the meantime, it works! I get the separate strings from a database and then merge it in FME with an Aggregator. Fantastic!


Reply