title: Regex value from input field
body: <p>I have a <code>$html</code> variable containing a lot of html code and I'm trying to extract the value from a certain parameter (this can be the value, or the class, etc.) out of an input field based on its id.</p>
  
  <p>An example of the code I'm trying to find:</p>
  
  <pre><code>&lt;input type="text" autocomplete="" name="confirmedEmailAddress" id="emailaddress" maxlength="60" value="fname.lname@gmail.com" class="txt-box  txtbox-m "  aria-describedby="" aria-required="true" disabled="disabled" /&gt;
  </code></pre>
  
  <p>I'm trying to build a regex that extracts the value (<code>fname.lname@gmail.com</code>) out of it, by telling it to find the value out of all <code>&lt;input&gt;</code> where <code>id="emailaddress"</code> - with wildcards between input and id, and between id and value (the only thing for sure is that input is before id which is before value).</p>
  
  <p>Here is my current PHP code (using preg_match_all because it's supposed to become a function I can reuse in cases where there are several fields):</p>
  
  <pre><code>$pattern = '&lt;input(.*)id="emailaddress"(.*)value="(.*?)"';
  preg_match_all('/'.$pattern.'/si',$html,$matches);
  </code></pre>
  
  <p>I've been trying variations but I either get the first input field or no match. Any help welcome! Thanks in advance.</p>