Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Substring?

Status
Not open for further replies.

mike314

Programmer
Jun 24, 2003
143
US
Got a quick one here

I have a textbox on my html page that access some text, but the problem is that the text contains a file extension like .jpg, .html, .wmv etc...

my loop doesn't work

for(var x = 0; x < files.length; x++) {
if (files.charAt(x) == ".")
{mover = mover + files;}
}

files is a variable

a sample input would be
/recent/temp/2/index.jpg

but basically I want just
/recent/temp/2/index

thanks, any help is much appreciated!
 
how about a regex to replace "a dot followed by one or more characters to the end of the line" with nothing?
Code:
 files = files.replace(/\..+$/, "");

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top