Question

AttributeTrimmer syntax? - removes more than it should

  • 14 January 2013
  • 3 replies
  • 7 views

Badge
Hello,

 

I'm trying to trim an attribute, as an example:

 

asi-n6250-20030111-v5

 

 

When I want to trim everything in front of 20030111-v5 (so removing asi-n6250-) it instead removes asi-n6250-200, so a 2 and two 0's too much. 

 

 

I've identified the problem to the point that when I put "asi-n6250" the result is "30111-v5" so the last minus doesn't seem to be the problem.

 

 

As an example the attached workspace:

 

http://speedy.sh/ZYeY8/AttributeTrimmer.fmw

 

 

I'm sure I'm missing something in the syntax but I couldn't find it in the documentation. 

 

 

FME2012, windows vista 

3 replies

Badge +14
I haven't used the AttributeTrimmer to trim off groups of different characters, I think its intended use is more to remove things like leading and trailing spaces.

 

 

I think in your case, I'd either use a SubStringExtractor from 10 to -1 to get the last part of your string into a new attribute or if the attribute can change length, the AttributeSplitter might be more useful, splitting on "-" and then simply concatenating list elements 2 and 3 with a "-" in between might be more flexible.
Userlevel 4
Badge +13
Another option can be making use of the StringReplacer with the test attribute and text to find: asi-n6250-, replacement " " (empty)
Badge
Both solutions worked great. As the strings change in length and in characters I went with the string replacer, though I could've made the attributesplitter work as well. Thanks a lot!

Reply