var regex = /^(.).*1$/; console.log( regex.test('abcdsa') ) console.log( regex.test('abcdsaasaw') ) Run code snippetHide results