Eliminate newlines in google app script using regex

It seems that in replaceText, to remove soft returns entered with ShiftENTER, you can use \v:

.replaceText("\\v+", "")

If you want to remove all “other” control characters (C0, DEL and C1 control codes), you may use

.replaceText("\\p{Cc}+", "")

Note that the \v pattern is a construct supported by JavaScript regex engine, and is considered to match a vertical tab character (≡ \013) by the RE2 regex library used in most Google products.

Leave a Comment