title: c# regex - all white space before <pre>
body: <p>Could you help me sort some regex.</p>
  
  <p>I want all the whitespace before the <code>&lt;pre&gt;</code></p>
  
  <pre><code>public Regex BeforePre = new Regex(@"^.*?(?=&lt;pre&gt;)", RegexOptions.Compiled);
  </code></pre>
  
  <p>That will select everything before the <code>&lt;pre&gt;</code>, not just the whitespace. I want to only select the whitespace.</p>
  
  <p>using <a href="http://regexstorm.net/tester" rel="nofollow">http://regexstorm.net/tester</a></p>
  
  <pre><code>Pattern: ^.*?(?=&lt;pre&gt;)
  
  Input: dewjdoiejw; test &lt;pre&gt;frfef&lt;/pre&gt;
  </code></pre>
  
  <p>I believe it's <code>\s</code> but I can not get it to work.</p>
  
  <p>Also I would like it so it works across multiple lines, for example:</p>
  
  <pre><code>Input: dewjdoiejw; test 
  
  &lt;pre&gt;frfef&lt;/pre&gt;
  </code></pre>
  
  <p>Please let me know if you need more info.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>see.... <a href="http://goo.gl/8mX5c3" rel="nofollow">http://goo.gl/8mX5c3</a> </p>
  
  <p>I want to remove all white space and tabs before <code>&lt;pre&gt;</code></p>
  
  <p>I only want to consider <strong>all</strong> text before <code>&lt;pre&gt;</code> and from that text remove all white-space/tabs.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>from </p>
  
  <pre><code>&lt;div&gt;
      &lt;div&gt;
         some text
  
          &lt;div&gt;some text&lt;/div&gt;     
      &lt;/div&gt;
  
      &lt;div&gt;some text&lt;/div&gt;   
  
  &lt;/div&gt;
  
  &lt;pre&gt;
     &lt;div&gt;
        &lt;div&gt;some text
  
        &lt;div&gt;some text&lt;/div&gt;
      &lt;/div&gt;
  
     &lt;div&gt;some text&lt;/div&gt;
  
     &lt;/div&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p>to </p>
  
  <pre><code>&lt;div&gt;&lt;div&gt;some text&lt;div&gt;some text&lt;/div&gt;&lt;/div&gt;&lt;div&gt;some text&lt;/div&gt;&lt;/div&gt;
  &lt;pre&gt;
     &lt;div&gt;
        &lt;div&gt;some text
  
        &lt;div&gt;some text&lt;/div&gt;
      &lt;/div&gt;
  
     &lt;div&gt;some text&lt;/div&gt;
  
     &lt;/div&gt;
  &lt;/pre&gt;
  </code></pre>