Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let textWords = input[0]
- let wordsToReplace = input[1]
- let regex = /\b(_+)(?=[\b.,]*)/g
- let match = regex.exec(textWords);
- while (match) {
- textWords = textWords.replace(match[0], wordsToReplace.find(w => w.length === match[0].length));
- match = regex.exec(textWords);
- }
- console.log(textWords)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement