title: Beginning and end of the string in Emacs regexps
body: <p>What is the characters that indicate the beginning and the end of the <em>string</em> with newlines in it? I'm writing a trim function:</p>
  
  <pre><code>(defun trim (str)
    (if (string-match "^[[:space:]]*\\(.+?\\)[[:space:]]*$" str)
        (match-string 1 str)
        str))
  </code></pre>
  
  <p>But with a string like "first/nnext" (got from <code>shell-command-to-string</code>) it returns only the "first". Reference manual says:</p>
  
  <blockquote>
    <p>When matching a string instead of a buffer, ‘^’ matches at the beginning of the
    string or after a newline character.</p>
  </blockquote>
  
  <p><code>\\'</code> and the left one are for beginning/end of a buffer, so it simply returns nothing from a string. Therefore, how to indicate the 'absolute' beginning of a string, if possible?</p>