Skip to main content

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

Hi @denizturan1985

If you have a excel source with all possibilities abbreviation?

Thanks


@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.


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.

 

 


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

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

 

 


Hi @denizturan1985

If you have a excel source with all possibilities abbreviation?

Thanks

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

 


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)


Reply