Replace a string

The below JavaScript can be used to search for a string and replace it with a different string, each instance of the string being searched for will be replaced

Replace(/stringtoreplace/g,'replace it with this')
 
An Example of using this in a script would be below, this would replace all spaces between characters with a comma.
 
[Text Area] = [Text Area].replace(/ /g,',');