Remove file extension

My varible “clip” equals a path to a image.
If you trace “clip” you get this.

includes/gallery/imageName.jpg

I have figured out how to remove includes/gallery/ with this

clip = clip.substr(clip.lastIndexOf("/")+1);

But I also need to remove the .jpg extension so all I am left wiith is “imageName”.

Any ideas?