Today I have a very quick tip but useful. I’ve wasted a few minutes of my life trying to find an answer for this because I’m not an expert when it comes to regular expressions.

This code comes in handy if you’re trying to remove \n (a break line) from a string and you want to replace it with something else (line a comma, as shown in the example below) you can use the following code:

string.replace(/[\r\n]+/g, ",");