title: Concatenate RTF files in PHP (REGEX)
body: <p>I've got a script that takes a user uploaded RTF document and merges in some person data into the letter (name, address, etc), and does this for multiple people. I merge the letter contents, then combine that with the next merge letter contents, for all people records.</p>
  
  <p>Affectively I'm combining a single RTF document into itself for as many people records to which I need to merge the letter. However, I need to first remove the closing RTF markup and opening of the RTF markup of each merge or else the RTF won't render correctly. This sounds like a job for regular expressions.</p>
  
  <p>Essentially I need a regex that will remove the entire string:</p>
  
  <p>}\n\page ANYTHING \par</p>
  
  <p>Example, this regex would match this:</p>
  
  <pre><code>crap
  }
  \page{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
  {\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\f0\fs20 September 30, 2008\par
  more crap
  </code></pre>
  
  <p>So I could make it just:</p>
  
  <pre><code>crap
  \page
  more crap
  </code></pre>
  
  <p>Is RegEx the best approach here?</p>
  
  <p>UPDATE: Why do I have to use RTF?</p>
  
  <p>I want to enable the user to upload a form letter that the system will then use to create the merged letters. Since RTF is plain text, I can do this pretty easily in code. I know, RTF is a disaster of a spec, but I don't know any other good alternative.</p>