Skip to main content
I'm trying to Find multiple attributes and replace with different text.

 

 

I'm not sure what syntax to use in the regular expression or to use a condition statement.

 

 

example:

 

Text to Find: Red OR Green OR Blue

 

Replacement Text: Stop,Go,Other

 

 

In the above example I want to find all the attributes that indicate Red with Stop . . .Green with Go .....etc.

 

 

Hi, 

 

 

have you tried the RegularExpressionMatcher from the FME Store? You can download it from within your workspace or http://fmestore.safe.com/transformers/RegularExpressionMatcher.htm

 

 

I've never tried it out, but I hope it helps. 

 

 

best regards, 

 

Jelle

 

 


Why not use the AttributeValueMapper?
Jelle, the issue is I do not know how to write the regular expression to select the two different attributes and replace with two different ones.

 

 

My solution was to use TWO StringReplacer transformers (which worked), but if their is a way of doing it through one I would like to know that method....

 

 


Hi,

 

 

I don't think we can process two or more attributes at the same time with only one regular expression.

 

 

As Jelle mentioned, the AttributeValueMapper works fine to replace an attribute value simply. The parameter settings would be like this.

 

Source Attribute: <attribute name>

 

Destination Attribute: <attribute name>

 

Mapping Direction: Foward (Source To Destination)

 

Value Map (Source Value | Destination Value):

 

  Red | Stop

 

  Green | Go

 

  Blue | Other    To do this for two different attributes, you can just use two AttributeValueMappers in a series.

 

As long as reading your first post, I think this would be a simple and enough solution.   If you want to do somehow the operation for multiple attributes using only one transformer, I think it will be necessary to use the PythonCaller or the AttributeCreator (with Tcl command).   Python script exmpale: ----- import fmeobjects   # Target attribute names AttrNames = n'attr1', 'attr2']   # Map: source to destination Mapper = {     'Red': 'Stop',     'Green': 'Go',     'Blue': 'Other'}   def processFeature(feature):     for name in AttrNames:         value = str(feature.getAttribute(name))         if value in Mapper:             feature.setAttribute(name, Mapper value]) -----   Tcl example to get a result similar to the AttributeValueMapper above is: @Evaluate(estring map {"Red" "Stop" "Green" "Go" "Blue" "Other"} "@Value(<attribute name>)"])   You can specify this expression to "Value" column of the AttributeCreator for multiple attributes.

 

Takashi
You can make use of stringPairReplacer . Would be something like Red Stop Green Go Blue Other , believe it works like this. Have a look. Regards, Jorge vidinha

Reply