title: Find specific div with RegEx and print content
body: <p>I'm trying to pull some text from an external website using <a href="http://icant.co.uk/articles/crossdomain-ajax-with-jquery/using-yql.html" rel="nofollow">this script</a>.</p>
  
  <p>It works perfectly, but it gets the entire page. I want to take only the content inside a specific div with the class 'content'. The entire page is put inside the variable 'data', and then this function is created to strip some tags:</p>
  
  <pre><code>function filterData(data){
    data = data.replace(/&lt;?\/body[^&gt;]*&gt;/g,'');
    data = data.replace(/[\r|\n]+/g,'');
    data = data.replace(/&lt;--[\S\s]*?--&gt;/g,'');
    data = data.replace(/&lt;noscript[^&gt;]*&gt;[\S\s]*?&lt;\/noscript&gt;/g,'');
    data = data.replace(/&lt;script[^&gt;]*&gt;[\S\s]*?&lt;\/script&gt;/g,'');
    data = data.replace(/&lt;script.*\/&gt;/,'');
    return data;
  }
  </code></pre>
  
  <p>How would I go about finding the div with the class 'content' and only viewing the content inside that?</p>
  
  <p><strong>UPDATE:</strong> Sorry about using RegExes — can you help me to get the content without using RegEx? So, this is my HTML file:</p>
  
  <pre><code>&lt;a href="http://www.eurest.dk/kantiner/228/all.asp?a=9" class="ajaxtrigger"&gt;erg&lt;/a&gt;
  &lt;div id="target" style="width:200px;height:500px;"&gt;&lt;/div&gt;
  &lt;div id="code" style="width:200px;height:200px;"&gt;&lt;/div&gt;
  &lt;script src="http://code.jquery.com/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
  var container = $('#target');
  $('.ajaxtrigger').click(function(){
  doAjax($(this).attr('href'));
  return false;
  });
  function doAjax(url){
  if(url.match('^http')){
  $.getJSON("http://query.yahooapis.com/v1/public/yql?"+
              "q=select%20*%20from%20html%20where%20url%3D%22"+
              encodeURIComponent(url)+
              "%22&amp;format=xml'&amp;callback=?",
      function(data){
        if(data.results[0]){
          var tree = string2dom(data.results[0]);
          container.html($("div.content", tree.doc));tree.destroy();
        } else {
          var errormsg = '&lt;p&gt;Error: could not load the page.&lt;/p&gt;';
          container.html(errormsg);
        }
      }
    );
  } else {
    $('#target').load(url);
  }
  }
  function filterData(data){
  
  return tree;
  }
  });
  &lt;/script&gt;
  </code></pre>