My original string = A abc, B xyz, C mlk ooo
How can I remove single letter of each element: A B C
?
Expected Output = abc, xyz, mlk ooo
My original string = A abc, B xyz, C mlk ooo
How can I remove single letter of each element: A B C
?
Expected Output = abc, xyz, mlk ooo
You could use a regex to replace a single letter (indicated by a letter with a word-break \b
on either side of it) followed by some number of spaces with nothing:
const str = "A abc, B xyz, C mlk ooo"
const output = str.replace(/\b[a-z]\b\s*/ig, '', str)
console.log(output)