Skip to main content
Solved

StringPairReplacer with Regular Expressions


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)

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

7 replies

danilo_fme
Evangelist
Forum|alt.badge.img+45
  • Evangelist
  • October 24, 2018

Hi @denizturan1985

If you have a excel source with all possibilities abbreviation?

Thanks


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • 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+46
  • Safer
  • 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+46
  • Safer
  • 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
  • October 25, 2018
gio wrote:

@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
  • October 25, 2018
danilo_fme wrote:

Hi @denizturan1985

If you have a excel source with all possibilities abbreviation?

Thanks

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

 


takashi
Evangelist
  • 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)


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