
Copy link to clipboard
Copied
Hi
How would you do that?
I need to test if
a) the string contains two consecutive backslashes
b), if not, test if there is at least one backslash
if(test.indexOf("\\") >= 0) seems to hit on a string that's "ss\\ss", but I have a feeling that's incorrect. I think it's really just testing for 1 backslash.
And AS3 doesn't let you do if(test.indexOf("\") >= 0), as the single backslash escapes the rest of your code.
It's for testing the existance of either single or double backslashes in ID3 tags, as some editors use either as a delimeter for multiple tags within the one tag category eg genre: rock\\pop, or rock\pop
Thanks for taking a look.
1 Correct answer
if(s.indexOf("\\\\")>-1){
//there are two or more consecutive backslashes
} else if(s.indexOf("\\")>-1){
// there is exactly one backslash
}
Copy link to clipboard
Copied
if(s.indexOf("\\\\")>-1){
//there are two or more consecutive backslashes
} else if(s.indexOf("\\")>-1){
// there is exactly one backslash
}

Copy link to clipboard
Copied
Cheers kGlad. Turns out double backslashes aren't getting picked up by the ID3 parser (Windows doesn't even seem to pick them up), but the single backslash works fantastic.
Much appreciated mate.
Copy link to clipboard
Copied
this "\\" will be read as one backslash. "\\\\" is two backslashes. "\\\\\\" is 3 backslashes etc.

