Skip to main content
Solved

String (dash) replacement in AttributeManager using ReplaceString


Forum|alt.badge.img

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

View original
Did this help you find an answer to your question?

3 replies

virtualcitymatt
Celebrity
Forum|alt.badge.img+35

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+35
virtualcitymatt wrote:

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

 


Forum|alt.badge.img
  • Author
  • 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...


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings