Skip to main content
Question

Suspicious Behavior of StringReplacer

  • November 4, 2018
  • 3 replies
  • 6 views

takashi
Celebrity

From this Q&A: Replace attribute values for all attributes

My first idea was to use a StringReplacer to replace every attribute with '0' if it matched the regex '^0*$' (0 or more '0'), '1' otherwise.

I thought it should work theoretically, but the StringReplacer replaced '0' with '1' in fact.

If you set a character (e.g. 'x') other than '0' to the Replacement Text parameter, it worked fine.

I'm afraid that there could be a bug here. See also the attached workspace.

(FME 2018.1.0.3)

Original:

Unexpected Result: Every <empty> was replace with '0', but '0' was replaced with '1'.

Comparison: Every '0' and <empty> was replaced with 'x'.

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

fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • November 5, 2018

Well I've just spent some time looking at this and trying a few things, and indeed, you seem to be right.

 

I find the same thing happens with a single "1" being replaced by "1" as well. So it is something about a single digit being replaced by the same thing causing us to think we haven't done anything to the text.

 

And as I typed that I figured out the issue. IF we replace with EXACTLY what was there to begin with, we THINK WE DID NOT DO ANYTHING!!! So then we go to the "expression not found" case. Clearly a bug. See my example below -- especially the very last string replacer where I replace "dale" with "dale" only to be told that no replacement was made. Very good catch Takashi!

smallreplacementtest.fmw


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • November 19, 2018

Hi @takashi. Our developer Shelley has reported this as fixed in version 5 of the transformer in FME 2019. To get the fix, please upgrade the transformer after opening your workspace in FME 2019.


takashi
Celebrity
  • Author
  • 7843 replies
  • November 19, 2018

Hi @takashi. Our developer Shelley has reported this as fixed in version 5 of the transformer in FME 2019. To get the fix, please upgrade the transformer after opening your workspace in FME 2019.

Thanks for the fix!