Converting Linux paths to Windows paths
I have a situation where I’m trying to convert a / to a \ in a string and it doesn’t seem possible using the standard replace() procedure we have. The test case is very simple.
var linuxPath = “somepath/somefile.txt”
var dosPath = replace(linuxPath, “/”, “\\”)
return dosPath
This will fail with missing closing quote because the \\” is interpreted is escaping the ” and not the \ in the replace subString. I can put a space in there like this “\ ” and that will work but now my dosPath is broken. Is there an easy way to convert the / to a \ or is this just one of those funky things that we have to learn to deal with?
Replies: 1
For interim you could work around like this.
var newname = replace(replace(filename, “/”, “\\ “),” “,””)
Hope this helps.
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.