Skip to main content
Solved

StringReplacer with Regex String via Feature Attribute


Forum|alt.badge.img

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?

Best answer by ebygomm

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

View original
Did this help you find an answer to your question?

12 replies

david_r
Celebrity
  • October 22, 2019

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.


Forum|alt.badge.img
  • Author
  • October 22, 2019

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


david_r
Celebrity
  • October 22, 2019
oiram wrote:

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?


Forum|alt.badge.img
  • Author
  • October 22, 2019
david_r wrote:

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

How can I determine this?


david_r
Celebrity
  • October 22, 2019
oiram wrote:

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.


Forum|alt.badge.img
  • Author
  • October 22, 2019
david_r wrote:

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!


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • Best Answer
  • October 22, 2019

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


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • October 22, 2019
oiram wrote:

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


Forum|alt.badge.img
  • Author
  • October 22, 2019
ebygomm wrote:

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!


Forum|alt.badge.img
  • Author
  • October 22, 2019
ebygomm wrote:

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.


ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • October 22, 2019
oiram wrote:

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.


Forum|alt.badge.img
  • Author
  • October 22, 2019
ebygomm wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings