Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Performs multiple replacements on a single string.
- * @param {string} str - The original string in which the replacements will be performed.
- * @param {[string, string][]} replacements - An array of tuples containing the search text and its corresponding replacement text.
- * @returns {string} The modified string with the replacements applied.
- */
- function replaceMultipleValues(str: string, replacements: [string, string][]): string {
- let result = str;
- for (const [searchText, replacementText] of replacements) {
- result = result.replace(new RegExp(searchText, 'g'), replacementText);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment