title: How do I find and replace using Regular Expressions in Google Docs Text Editor?
body: <p>I'm trying to import my notes from Kindle into a Google Doc (you can view it <a href="https://docs.google.com/document/d/1LG75VBG5JfW8V5NOKzzmdHw4Dbd3nR4aQB3uzLTVtIE/edit" rel="nofollow">here</a>), and I have a document in which I want to strip out all of the occurrences of the following text (including the line break): </p>
  
  <blockquote>
    <p>Read more at location 6567   • Delete this highlight<br>
    Add a note </p>
  </blockquote>
  
  <p>I came up with the following search pattern and tested it on <a href="https://docs.google.com/spreadsheets/d/1f4qGg4JiQZwVDW90fQjvc0CcehYnJf7GZONYKXBK5LM/edit#gid=0" rel="nofollow">this google sheet</a> to make sure my regex syntax works: </p>
  
  <pre><code>"Read more at location (\d*)   • Delete this highlight\nAdd a note"
  </code></pre>
  
  <p>Then I created a google apps script, and have it load in my document: </p>
  
  <pre><code>function onOpen() {
    DocumentApp.getUi() // Or DocumentApp or FormApp.
        .createMenu('AdvancedFind&amp;Replace')
        .addItem('Remove Kindle HTML', 'findAndReplace')
        .addToUi();
  }
  
  // In-Document Find and Replace
  
  function findAndReplace() {
    var body = DocumentApp.getActiveDocument().getBody();
      body.replaceText("Read more at location (\d*)   • Delete this highlight\nAdd a note", "");
        }
  </code></pre>
  
  <p>However, when I run it, it doesn't replace the text. I think it's a problem with the REGEX, because when I run this code instead, it works:</p>
  
  <pre><code>function replaceBat() {
    var body = DocumentApp.getActiveDocument().getBody();
      body.replaceText("BBat", "BBAat REPLACEMENT SUCCESSFUL");
        }
  </code></pre>
  
  <p>Any help would be greatly appreciated, thanks!</p>