Skip to main content
Solved

StringPairReplacer with Regular Expressions

  • October 24, 2018
  • 7 replies
  • 91 views

denizturan1985
Participant
Forum|alt.badge.img

Hello all,

I have an issue with StringPairReplacer. I want to use the word boundaries function in this transformer but it's not available.

PairsBeforeAfter1TransportTrans.2WorkWks.

ResultBeforeAfter1Deniz TransportationDeniz Trans.port2NetworkNetWks

I want to manipulate only "Transport" and "Work" words not "Transportation" and "Networks".

Is there any workaround for this issue? StringReplacer is not easy to use for a huge abbreviation list. I need to add hundreds of StringReplacer transformer for each case.

Thank you

Best answer by takashi

I think it requires writing a script or defining a custom transformer with loop if you need a generic solution. This is a custom transformer example: loop-stringreplacer.fmwt (FME 2018.1.0.3)

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.

7 replies

danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • October 24, 2018

Hi @denizturan1985

If you have a excel source with all possibilities abbreviation?

Thanks


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • 2252 replies
  • October 24, 2018

@denizturan1985

You can use wordboundaries to limit the reg expression using a stringreplacer.

\\bwork\\b

Or use tcl stringmap function

Or indeed use a valuemap in a txt file (or excel or)

Or use a valuemapper and enter the map, or import the map from a txt file.

The stringpairreplacer does not allow for regexp searching, alas.


mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • October 24, 2018
Yes, sadly the StringReplacer only does one set of substitutions (even if it is on multiple attributes). There is an idea you might want to vote up - see https://knowledge.safe.com/content/idea/19769/improve-stringreplacer-to-allow-multiple-string-re.html - it already has 25 upvotes so it's already fairly high on the list and I imagine we will want to do this update in the not-too-distant future.

 

 


mark2atsafe
Safer
Forum|alt.badge.img+56
  • Safer
  • 2554 replies
  • October 24, 2018

Rather than multiple StringReplacers you can use a single AttributeManager - for each attribute click the drop-down arrow to the right and then choose Conditional. There you will be able to set various clauses and the text editor dialog under the conditional test conditions should allow you to include regular expressions.


denizturan1985
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • 11 replies
  • October 25, 2018

@denizturan1985

You can use wordboundaries to limit the reg expression using a stringreplacer.

\\bwork\\b

Or use tcl stringmap function

Or indeed use a valuemap in a txt file (or excel or)

Or use a valuemapper and enter the map, or import the map from a txt file.

The stringpairreplacer does not allow for regexp searching, alas.

I will check these transformers and share the result. Thank you @gio

 

 


denizturan1985
Participant
Forum|alt.badge.img
  • Author
  • Participant
  • 11 replies
  • October 25, 2018

Hi @denizturan1985

If you have a excel source with all possibilities abbreviation?

Thanks

Yes, Updating repository is another solution. thank you @danilo_fme

 


takashi
Celebrity
  • 7843 replies
  • Best Answer
  • October 26, 2018

I think it requires writing a script or defining a custom transformer with loop if you need a generic solution. This is a custom transformer example: loop-stringreplacer.fmwt (FME 2018.1.0.3)