I am having a trouble with removing all spaces from a string.
Stehn Stehn Simchart Simchart Stehn Stehn Stehn Stehn Stehn This is the string, which has new lines, spaces, and so on.
string.replace(/[\r\n]+/gm, ', ') Doing this, only returns me
Stehn , Stehn , Simchart, Simchart, Stehn , Stehn , Orion Reederei GmbH & Co KG, Orion Reederei GmbH & Co KG, Stehn , Stehn , Stehn , Arrow Shipping Germany, "
But I would like to get a normalized and sanitized string with commas.
string.replace(/\r?\n|\r/g, ',').split(',').map(s => s.trim()).join(', ') This code, however, resolves my problem, but I don't like this solution as I have thousands inside my table.
\smatches any whitespace character - is that what you need?\shelp? You want all whitespace to be replaced so it seems like the logical choice. If it doesn't work, then there is something that isn't present in the question.Orion Reederei GmbH & Co KGand it has spaces but not replaceable.