SyntaxFix
Write A Post
Hire A Developer
Questions
A simple answer without any regex would be:
str = str.substr(0, str.lastIndexOf(list[i])) + 'finish'