How to code IndexOf "Music\" in a string


#1

How do I code IndexOf(Playlist, ‘Music’)? The backward slash is a problem.


#2

Have you tried '\\' ?


#3

Yep, it gives me a -1 in “G:\iPod Music\4 Non Blondes - What’s Up.mp3”


#4

Hmm, I was thinking of getting creative and do a replace() of the slash but my replacement isn’t showing up either lol.

(expression) replace(str,'\\','@') »»» (string) G:iPod Music4 Non Blondes - What’s Up.mp3

In my old IRC days the chat program we used can do a search replace in this tricky situation by using the ascii value of the character, in this situation would be $chr(92) and then the reverse


#5

I don’t have webCoRE available to test. If I was testing it I’d try \\\\ as that wouldn’t be without precedent.


#6

Does this Playlist value come from a variable? How was it entered in to webCoRE?

If you are entering the value directly the issue may be on the data entry side rather than retrieval. The following results in a value that looks correct when displayed in the “code view” but does not actually work.

With the value entered that way, check out what is logged by the following piston:

+65ms ║-1
+79ms ║-1
+92ms ║-1
+103ms ║-1
+115ms ║-1
+125ms ║2
+134ms ║G:iPod Music4 Non Blondes - What’s Up.mp3

The last line tells it all, the backslashes in the Value field have escaped the character that follows them rather than remaining as backslashes. In this example you would have to use double backslashes in the Value field and even then only the backslash variable approach seems to work.

There are some quirks here but in order to go farther, may this be what you were experiencing or was the value coming from somewhere else that should have handled the backslash properly?


#7

He read it from a file, so it went into a new system variable $file

We do have questions open on the HE side for file upload/download checking the fidelity both ways.

There are two parts to this, the file name and file contents.


#8

So it seems the work around is to use a variable for the search of indexOf. (thx to @ipaterson )

  • this works for both ‘\’ and ‘\\’ type checks

08%20PM

and:

27%20PM