I want to change lines of this form:
one line find text
into this a pair of lines of this form:
first line of replace text
second line of replace text
I know that one can search for a newline by checking the "Match using regular expressions" box, and filling in \n
in the "Find" box. But \n
in the "Replace with" box appears to insert \n
into the results, rather than the desired newline.
I tried using this search-and-replace, but it hasn't worked for me:
Find `one line of find text`
Replace with `first line of replace text\nsecond line of replace text`
My next strategy was to use the regular expression matching construct of a parenthesized regular expression in the Find box and a $
[number] expression in the Replace with box, but it also didn't work for me:
Find `(\n)one line of find text`
Replace with `$1first line of replace text$1second line of replace text`
Is there a way to do this in Google Docs at all, or must I export to a more capable word processor (such as Word or Libre Office), do the find-and-replace there, and import back to Google Docs?
Note 1: I'm describing Google Docs behavior as of July 2019. It's possible that this is a missing feature for now, but will be a functional feature in the future, which could flip answers between right and wrong (unless they include "as of" qualifiers).
Note 2: The question "Regular Expression Carriage Return Find & Replace on Google Docs" appears to address a similar question, but it's not worded clearly enough for me to tell whether it's a duplicate. The one answer mentions an "HTML mode", but I don't see such a mode in Google Docs.
text.replaceText('one line of find text', 'first line of replace text\nsecond line of replace text');
works fine making all replacements at once. – Hazlett