I got a strange problem with split function over the String. Please look at my example, How can I figure it out? Does It remove “\” from String by default?
public function code01():void {
qrShow("C:/Documents and Settings/me/Desktop/a.gif;C:/Documents and Settings/me/Desktop/b.gif");
qrShow("C:\Documents and Settings\me\Desktop\a.gif;C:\Documents and Settings\me\Desktop\b.gif");
}
public function qrShow(u:String):void{
var imgArray:Array = u.split(";");
for each(var addrs:String in imgArray) {
trace (" --- " + addrs);
}
}
The result is as follows:
— C:/Documents and Settings/me/Desktop/a.gif
— C:/Documents and Settings/me/Desktop/b.gif
— C:Documents and SettingsmeDesktopa.gif <— why no “\” ?
— C:Documents and SettingsmeDesktop.gif <— why no “\” and also “b” is changed !!!?
Is this a bug in Flash?
You need to escape a backslash (with another backslash).
For example try run this:
You’ll get an error.
You need to do this: