Skip to main content

I'll be the first to admit this may be a dumb newbie question, but I'm struggling!

 

I have an input field that contains a file path like the following:

q:\\staging\\incoming\\1930s\\WI\\Sauk\\1937\\Sauk_WI_WU_11_908_19370707.tif

I need to construct a URL to the file as referenced in a URL, and dump it into another field:

https://server.com/1930s/WI/Sauk/1937/Sauk_WI_WU_11_908_19370707.tif

 

My conceptual approach has been to use string processing to replace q:\\staging\\incoming with https://server.com, and then replace backslashes with forward slashes.

 

Well, you can see where this is going... the slashes and backslashes are wreaking havoc.

 

For example, I've tried various combinations to escape the \\, like:

@ReplaceString(@Value(inputpath),"/\\","/")

... but I either get no results, or a syntax notice.

 

Am I even in the ballpark?? I'd love some suggestions on how to approach this issue.

 

 

Have you tried the StringReplacer?


Thanks. I just played with the StringReplacer transformer, and it looks like that will work fine with no fuss. This is where my ignorance/newness of FME shows through. I'm attempting to handle many of my manipulations in the Attribute Manager transformer. That is, I'm still trying to understand when to use a transformer like StringReplacer vs string function like ReplaceString.


Thanks. I just played with the StringReplacer transformer, and it looks like that will work fine with no fuss. This is where my ignorance/newness of FME shows through. I'm attempting to handle many of my manipulations in the Attribute Manager transformer. That is, I'm still trying to understand when to use a transformer like StringReplacer vs string function like ReplaceString.

The ReplaceString function is handy, and I use it all the time actually. But when you have special characters like backslashes, commas or apostrophes to replace, it can get confusing trying to escape these in the syntax. That's when I usually use the StringReplacer.


Thanks. I just played with the StringReplacer transformer, and it looks like that will work fine with no fuss. This is where my ignorance/newness of FME shows through. I'm attempting to handle many of my manipulations in the Attribute Manager transformer. That is, I'm still trying to understand when to use a transformer like StringReplacer vs string function like ReplaceString.

In more general terms, while you can do a lot of stuff using functions in the AttributeManager I find it's often easier to manage if you use separate transformers for it. In this particular case the StringReplacer is definitely easier to set up. Just 2 of them would do the trick, no need to use Regular Expressions or anything.


Thanks for the tips, much appreciated!


No need to quote or escape backslashes

@ReplaceString(@Value(inputpath),\,/)

image


Reply