Skip to main content
Question

Suspicious Behavior of StringReplacer


takashi
Contributor
Forum|alt.badge.img+19

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'.

3 replies

fmelizard
Contributor
Forum|alt.badge.img+17
  • Contributor
  • 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
Contributor
Forum|alt.badge.img+17
  • Contributor
  • 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
Contributor
Forum|alt.badge.img+19
  • Author
  • Contributor
  • November 19, 2018
fmelizard wrote:

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!


Reply


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