Skip to main content
hi experts

 

 

do you know if the string replacer can be used with conditional mapping to replace multiple strings  instead of using a few string replacers ?

 

 

i tried a few options but havent got it working 

 

 

appreciate your help and suggestions 
Hi,

 

 

Could you please post some examples which describe what you need to do?

 

I'm guessing that the StringReplacer with regular expression, or the StringPairReplacer help you.

 

 

Takashi
For multiples you can just use a creator and tcl regsub function.

 

 

 


Or u can also use

 

 a creator with hstring map {mappingpairs} string ]

 

 

Here is one to clean "bad" language....;)

 

 

 

 

..if this is what u meant.

 


@Gio, recently I have been exploring "<FME HOME>/transformers/fmesuite.fmx".

 

If you peek at the file, you can see that many transformers are implemented with Tcl commands, especially for string operations. The StringReplacer calls "regsub" and "string map"; the StringPairReplacer is a wrapper of "string map".

 

That's very interesting - the FME Internal 🙂
Yes, i was aware of that for a long time.

 

In some post David, i think it was David even mentioned that FEM uses a lot of tcl.

 

 

The implementations are limited compared to what one can do by using creators.

 

In the string class transformers regexp use is very limited, u cant do forward (positive nor negative) lookups, u cant use switches etc.etc.

 

In attributeCreators u can use almost the full range of tcl (i even have one that executes a .exe from within a creator..lol).

 

Also you can nest them (seammingly) indefinitely.

 

 

nesting: @Evaluate(@lsort -unique tsplit {"@Value(text_line_data)"} {}]])

 

Wich makes the AttributeCreeator extremely powerfull.

 

 

Prior to conditionla merging, conditionalmerging was already possible...by using tcl.

 

 

The hard or convoluted bit is the need to use the @Evaluate() at correct moments in a tcl in an attributecreator...

 

 

input: "Hello/DearFmeCommunity"

 

 

tcl1:

 

@Evaluate(:regsub -all {(ua-z])/*(sA-Z])} "@Value(tststr)" {\\1@Evaluate(@Evaluate(@regexp -all {la-z](/+)gA-Z]} "@Value(tststr)" M m])==1?",":"" "")\\2}])

 

 

output:

 

Hello,Dear,Fme,Community

 

 

 

I have some that are truly unreadable...lol.

 

 

 

I made a couple of scripts in this forum showing this.

 

This is on the forum somewhere, about reading data out of a html fragment:

 

 

 

 

 

=>string range {@Value(html_txt)} >expr ilindex elindex "@Value(tags_idxs)"  @Value(Ind)] 0] +1] sexpr )lindex  lindex "@Value(tags_idxs)"  @Value(Ind)] 1]-1]]

 

 

 

Also tcl allows one to add missing FME transformers like

 

 

 


Reply