Well, if the string really ends with the pattern, you could do this:
str = str.replace(new RegExp(list[i] + '$'), 'finish');
More Related Contents:
- How to replace all occurrences of a string in JavaScript
- How do I replace a character at a particular index in JavaScript?
- Replace multiple strings with multiple other strings
- Fastest method to replace all instances of a character in a string [duplicate]
- How to replace all dots in a string using JavaScript
- How to replace all occurrences of a string in JavaScript
- How can I remove a character from a string using JavaScript?
- Remove whitespace and line breaks between HTML elements using jQuery
- Case insensitive string replacement in JavaScript?
- How do I replace all occurrences of a string in JavaScript?
- Efficient Javascript String Replacement
- Insert space before capital letters
- JavaScript – Replace all commas in a string [duplicate]
- Reformat string containing date with Javascript
- `string.replace` doesn’t change the variable [duplicate]
- Replace spaces with dashes and make all letters lower-case
- Javascript – Replacing the escape character in a string literal
- Repeat a string in JavaScript a number of times
- How to remove text from a string?
- How to find indices of all occurrences of one string in another in JavaScript?
- How to convert text to binary code in JavaScript?
- How do I escape a string inside JavaScript code inside an onClick handler?
- Convert javascript array to string
- Remove a character at a certain position in a string – javascript [duplicate]
- How to trim() white spaces from a string?
- Find difference between two strings in JavaScript
- Javascript string size limit: 256 MB for me – is it the same for all browsers?
- How to check if a string is a legal “dd/mm/yyyy” date?
- Logical operator && and two strings in javascript
- How to get text between two characters?