I have a string that looks like this: \"Doe, John, A\" (lastname, firstname, middle initial).
I\'m trying to write a regular expression that converts the string into \"D
Try this out to remove all spaces and commas, then replace with *.
Myname= myname.replace(/[,\s]/,"*")
Editted as removing 'at least two items' from the pattern. But to have at least on item.
Myname= myname.replace(/([,\s]{1,})/,"*")
Reference: on Rublar. However you are better off with regexpal as per m.buettner :)