title: Converting "$$...$$" into "\[...\]" in emacs with replace-regexp
body: <p>I'm trying to use emacs to convert strings of the form "$$...$$" into "\[...\]". I just started learning to use emacs for this specific purpose for editing some files.</p>
  
  <p>Following the <a href="http://www.emacswiki.org/emacs/ReplaceRegexp#toc1" rel="nofollow">first example</a> of replace-regexp on emacs wiki, I intitially tried:</p>
  
  <pre><code> M-x replace-regexp
   Replace regexp: \$\$.*\$\$
   Replace regexp with: \,("\[" \1 "\]")
  </code></pre>
  
  <p>but I received the error: <code>invalid function "["</code>. I instead tried</p>
  
  <pre><code>Replace regexp with: "\["\1"\]"
  </code></pre>
  
  <p>but I received the error: <code>Invalid use of `\' in replacement text</code>.</p>
  
  <p>Since neither of those approaches worked, I tried to adapt the <a href="http://www.emacswiki.org/emacs/ReplaceRegexp#toc13" rel="nofollow">13th example</a> of replace-regexp on emacs wiki, writing</p>
  
  <pre><code>M-x replace-regexp
  Replace regexp: \$\$
  Replace regexp with: \,(if (evenp \#) "\[" "\]")
  </code></pre>
  
  <p>but I received the error: <code>(void-function evenp)</code>. Any suggestions? I'd like to understand what went wrong in each of these instances, and how to fix them.</p>