Google-sheets – How to eliminate extra line breaks in a Google Spreadsheets cell

google sheets

I have a spreadsheet in which some cells have multiple carriage returns. I would like to eliminate all the extras, so that four carriage returns shrinks down to just one.

Screenshot

This question is similar to How to freeze row height?, and In a Google Spreadsheet, how can I force a row to be a certain height?, but since there are new lines / carriage returns in the text, turning off text wrapping does not work.

Is there an easy formula to do this?

I can't do it with a simple find/replace because the length of the line breaks varies.

Best Answer

Here is what I did.

  1. Hit ctrl+f to search, and click the "..." button representing more options

    Screenshot

  2. Typed \s+$ or \n in the find field

  3. I left the replace field empty
  4. Clicked "Search Using RegEx"
  5. Clicked replace

I hope it works for you. Also, you can replace \n with any regex expression and it can be immensely helpful.