"Christopher Brandsdal" wrote:
How do i cut the last 4 characters in a string?
I know how to cut the 4 first, but i need to cut
the last! I have a image name like testimage.gif
and I want to cut away .gif
Easy way:
filename.replace(/\.[^.]*?$/,"")
Silly way:
filename.split("").reverse().slice(4).reverse().jo in("")
Both JScript. The regular expression will properly handle extensions of
variable length (jpg or jpeg), and will not totally hose such filenames as
"My.oddly.named.filename.gif".
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.