Skip to main content
Solved

String (dash) replacement in AttributeManager using ReplaceString

  • July 19, 2023
  • 3 replies
  • 555 views

mzuer
Contributor
Forum|alt.badge.img+5

Dear All,

 

in the attribute "id" I have strings that have the following format

411d8e4d-2de6-0f5b-e100-00000a4c0a0d

I would like to remove the dash in an AttributeManager (I know, I could do it with StringReplacer). I've tried the following formula :

@ReplaceString(@Value(id), "-", ""))

but it does not work (id remain unchanged), whereas the formula with FindString here below gives the expected result (8).

@FindString(@Value(id),"-")

 Why the FindString is working but not ReplaceString ? What am I doing wrong ?

I was also able to do it in the regular expression-way, 

@ReplaceRegularExpression(@Value(id),"\-","")

 but I don't understand how ReplaceString works. Has anyone an explanation ?

Thanks in advance

Best answer by virtualcitymatt

Interesting find. You can just put the "-" in your call without the quotes

@ReplaceString(@Value(id),-,"")

it looks like FME will also look for the " marks in the actual string as well. Funnily enough though you need to specify the "" in the output to indicate an empty string. A bit weird

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

virtualcitymatt
Celebrity
Forum|alt.badge.img+47

Interesting find. You can just put the "-" in your call without the quotes

@ReplaceString(@Value(id),-,"")

it looks like FME will also look for the " marks in the actual string as well. Funnily enough though you need to specify the "" in the output to indicate an empty string. A bit weird


virtualcitymatt
Celebrity
Forum|alt.badge.img+47

Interesting find. You can just put the "-" in your call without the quotes

@ReplaceString(@Value(id),-,"")

it looks like FME will also look for the " marks in the actual string as well. Funnily enough though you need to specify the "" in the output to indicate an empty string. A bit weird

Ahh indeed I also tried 

@ReplaceString(@Value(id),"-","")

which worked - but if there is a <space> after the first comma it doesn't. I guess it's trying to find the <space> as well. Indeed if I do this, where the space is in the replace part:

@ReplaceString(@Value(_uuid),"-", "")

I end up with something like this:

c6a533b5 ""d76f ""4109 ""99c8 ""a59a66c9750c

 


mzuer
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • July 19, 2023

thanks a lot for the explanation !!! my question sounds really stupid now 😖 I am such a newbie... I'll never get used to the subtleties of FME...