var a = "some string",b = "some stringpdf",c = "some string.pdf" alert([!/\.pdf$/.test(a),!/\.pdf$/.test(b),!/\.pdf$/.test(c)]);