I have the text in the string below:
string = "ele, joao gosta de maria, mas maria gosta de jose";
string = string.replace(/???/g,", ");
See that some words have more or less spaces between them, and may still have commas after a word, but never a space before a comma.
How to build a Regex in replace
to get the result below?
ele, joao, gosta, de, maria, mas, maria, gosta, de, jose
That is, each word separated by a comma and a space .
I tried something like this: string = string.replace(/,\s+/g,", ");
but it did not work very well. Comma left over.