Skip to main content
Solved

StringReplacer with Regex String via Feature Attribute

  • October 22, 2019
  • 12 replies
  • 121 views

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

12 replies

david_r
Celebrity
  • 8394 replies
  • 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
  • 29 replies
  • 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
  • 8394 replies
  • 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

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


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

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

How can I determine this?


david_r
Celebrity
  • 8394 replies
  • October 22, 2019

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
  • 29 replies
  • October 22, 2019

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+44
  • Influencer
  • 3427 replies
  • 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+44
  • Influencer
  • 3427 replies
  • October 22, 2019

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
  • 29 replies
  • 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

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
  • 29 replies
  • 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

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


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • October 22, 2019

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
  • 29 replies
  • October 22, 2019

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!