title: Are there any good examples of document parsing in php?
body: <p>I am new to the php language.
  I wanted to know about some good examples on how to parse a word document with the extension <code>.doc</code> and extract the data from the document in the <code>HTML</code> form for example matching the correct data from the document (with the extension <code>.doc</code>) and finally inserting the data in the <code>HTML</code> form like Name, Date of Birth, Email Address etc in php.
  I have started doing some pattern matching using <code>regular expressions</code> but it has become very difficult to match the correct type of data and insert it in the right field.</p>
  
  <p>for example:</p>
  
  <pre><code>preg_match('/^[A-Za-z]+[A-Za-z]{3}/',$mastercontent,$matches);
  $name=$matches[0];
  </code></pre>
  
  <p>here <strong><code>$mastercontent</code></strong> consists of the data from the document i want to match my fields like name, date of birth etc with.
  <strong><code>$name</code></strong> is the field where i am inserting the data in the form after matching it.</p>
  
  <p>I was able to match the name but for other fields, it is showing an error if i use the similar method. But by using the <code>trim()</code> function in php, i am able to achieve this. But by using this function, the data becomes static and not dynamic. I needed some help with this.</p>