title: sed within AppleScript
body: <p>I'm trying to use a regex in an AppleScript, to set two variables to different substrings of some text which is in the following format and on the system clipboard (though the text and URL can vary arbitrarily, and there will often be an empty line after the URL):</p>
  
  <pre><code>This is a webapge title
  http://url.foo.com/ 
  </code></pre>
  
  <p>I want to assign the first line to <code>pageTitle</code>, and the second to <code>pageURL</code>, and ignore everything else. The AppleScript I thought would do this is:</p>
  
  <pre><code>set titleURL to the clipboard
  set pageTitle to (do shell script "echo \"" &amp; titleURL &amp; "\" | sed -E 's#(.*)\\n(.*)\\n?#\\1#'")
  set pageURL to (do shell script "echo \"" &amp; titleURL &amp; "\" | sed -E 's#(.*)\\n(.*)\\n?#\\2#'")
  </code></pre>
  
  <p>The regex does what I want <a href="https://regex101.com/r/mV9dZ3/4" rel="nofollow">when I test it on regex101.com</a>, but the AppleScript returns the entire string, untouched, for both variables. Am I missing something obvious?</p>