> Can someone tell me how do i find the last occurrence of the "\"
character in a file name.
retVal = "\data\sheet\file.gif"
lastPos = retVal.lastIndexOf("\",0);
This code keeps erroring !!!
the lastPos is correct. The problem is in the first statement.
The \ is the symbol for escaping. Supose you want to put
"starbuck's" in a string using single quotes to surround it.
This is impossible to do:
s = 'starbuck's'
Will error, and you can see why. So you have the escape the character.
s = 'starbuck\'s'
Escaping only works to create certain special characters for exampple:
\" = "
\' = '
\n = enter
\t = tab
\\ = \
You should be able to figure out the rest.
Good luck,
Vincent