// JS REGEX FOR LAST OCCURENCE: const str = "This is the first KEYWORD and this is the last KEYWORD"; str.match(/(KEYWORD)(?!.*1)/g) //=> ["KEYWORD"] // Using lastIndexOf(): str.lastIndexOf("KEYWORD") //=> 47