Closed Thread Icon

Preserved Topic: string manipulation? Pages that link to <a href="https://ozoneasylum.com/backlink?for=18507" title="Pages that link to Preserved Topic: string manipulation?" rel="nofollow" >Preserved Topic: string manipulation?\

 
Author Thread
911
Paranoid (IV) Inmate

From: Stuttgart, Germany
Insane since: Apr 2001

posted posted 10-09-2001 13:05

hi all!

i´ve gat a string like this:

code:
var xxx = "c:\xxx\yyy.html";


now i want to manipulate this string, so that i only got the filename in my var xxx. how can i do this in js?(in php it´s pretty easy, but in js?)

p.s.: i used the search to find an old topic about this problem, but didn´t find anything. but maybe there is one.(mrmax?);-)


lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 10-09-2001 15:03
code:
<script language="JavaScript">
<!--
var xxx = "c:\\xxx\\yyy.html";
alert(xxx.match(/[^\\]+$/));
//-->
</script>



lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 10-09-2001 15:10

bloody netscape, the last one doesn't work in netscape...

try this:

code:
<script language="JavaScript">
<!--
var xxx = "c:\\xxx\\yyy.html";
xxx = xxx.substr(xxx.lastIndexOf('\\')+1);
alert(xxx);
//-->
</script>



911
Paranoid (IV) Inmate

From: Stuttgart, Germany
Insane since: Apr 2001

posted posted 10-09-2001 15:22

thx! your code worked fine!

« BackwardsOnwards »

Show Forum Drop Down Menu