find the last occurrence of a character in a string javascript
str.lastIndexOf(searchValue[, fromIndex])
find the last occurrence of a character in a string javascript
str.lastIndexOf(searchValue[, fromIndex])
js regex last occurrence
// 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
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us