Multiline regex within a cell in Google Sheets
1 min readNov 17, 2018
Cells in Google Sheets can have multiple lines of text, and sometimes you need to match an expression over these lines. REGEXEXTRACT
, REGEXMATCH
, and REGEXREPLACE
don’t match new line characters with .
-expressions by default:
You can add the s
flag to match multiple lines in the same cell:
So if you want to match regular expressions against multiple lines in Google Sheets, use this formula:
=REGEXEXTRACT(A1, ".(?s)(.*)")
The full regex syntax used by Google Sheets can be found here: https://github.com/google/re2/wiki/Syntax