|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Say I've got something like this:
C:WINDOWSDesktopDeviantRun-Factor71-0.jpg And I want something like this: DeviantRun-Factor71-0.jpg How would I do that? It's basically taking everything after the final backslash. Thanks! Ryan |
|
#2
|
|||
|
|||
|
I'm not sure I understand your question, but if all you want to do is treat the path as a string and pull out the name of the file...
I realize this is the JavaScript Forum, but you could use Visual Basic and say: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>filename_Array=Split(filepath,"") 'your filename will always be the last element in the array, so... filename=filename(UBound(filename))[/code] I just made that up, so if it doesn't work, I apologize in advance... What are you trying to do anyway? [This message has been edited by billyo (edited July 06, 2000).] |
|
#3
|
|||
|
|||
|
I'm just browsing in a JavaSCript book, this is what i've found:
lastIndexOf(character,[fromIndex]) I could imagine that if you omit [fromIndex] (it's optional!) you get a search done on the string you specify from back to front (right to left) and the result is the index of that occurrence. Hence, you may do some "substring(starIndex,endIndex)", where startIndex is the value you got out from the previous function. You only have first also to count how long the string is, but that's the easiest part. Hope I can help!!! |
|
#4
|
|||
|
|||
|
Here's how I ended up solving it:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <SCRIPT LANGUAGE="JavaScript"> function find_fname() { var string = form1.file.value; var separator = ''; var stringArray = string.split(separator); for (var i=0; i < stringArray.length; i++) var final = stringArray[i]; form1.fname.value = final; } </script> [/code] |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > need regular expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|