HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 6th, 2000, 04:57 PM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
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

Reply With Quote
  #2  
Old July 6th, 2000, 09:20 PM
billyo billyo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 114 billyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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).]

Reply With Quote
  #3  
Old July 7th, 2000, 09:14 AM
bonnyfused bonnyfused is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 6 bonnyfused User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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!!!


Reply With Quote
  #4  
Old July 7th, 2000, 09:16 AM
scream scream is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Posts: 441 scream User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 59 m 38 sec
Reputation Power: 9
Send a message via ICQ to scream
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]

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > need regular expression


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway