title: Regex that replaces a css value in CSS
body: <p>Hey.
  I'm trying to parse a CSS file using PHP. </p>
  
  <p>I'm trying to run this expression:</p>
  
  <pre><code>"/(". $selector . "\\s*{[\\w\\s:\\-;()#]*)(" . $property . ":)([^;}]+)(}?)/Ui"
  </code></pre>
  
  <p>This regex is supposed to pin down a specific property within a selector and allow me to change it's value/remove it.</p>
  
  <p>rational:</p>
  
  <ol>
  <li>match the selector and it's text preceding to the property</li>
  <li>match the property name</li>
  <li>match the property value</li>
  <li>if the value ends by the } sign - catch it as well</li>
  </ol>
  
  <p>The broken bit is #3 - For some unknown reason, when I run this through preg_match, the value group(#3) only catches the first char.</p>
  
  <p>For example, running this expression:</p>
  
  <pre><code>preg_replace("/(h1\s*{[\w\s:\-;()#]*)(font-size:)(([^;}])+)(}?)/Ui","$1 $4",$css);
  </code></pre>
  
  <p>(find the font-size property of the h1 selector, and remove the property and value)</p>
  
  <p>on this css group:</p>
  
  <pre><code>h1{
      background:#fff;
      font-size:10px;
      text-align:underline;
      color:#abc;
  }
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>h1{
      background:#fff;
      /* note that although the property was matched and removed,
         the value only matched the 1st char: 1 */ 
      0px; 
      text-align:underline;
      color:#abc;
  }
  </code></pre>
  
  <p>I've tried to check the expression through some test tools and it worked fine, so I'm guessing this is a preg* specific problem. </p>
  
  <p>any ideas what I'm doing wrong?</p>