I am trying to complete a coding challange on CodeWars and i am trying to use a regex expression instead of splitting it into an array etc.
My code is
const removeDuplicateWords = s => s.replace(/(\b\S.+\b)(?=.*\1)/g, "")
removeDuplicateWords('alpha beta beta gamma gamma gamma delta alpha beta beta gamma gamma gamma delta');
I have gotten to a point that it replaces all the duplicates but I cannot get rid of the white space at the beginning.
Native Browser JavaScript
=> ' alpha beta gamma delta'
can anyone help, please?