title: jQuery + regular expression to replace href and src values inside textarea
body: <p>I have various textareas:</p>
  
  <pre><code>&lt;textarea&gt;&lt;a href="/"&gt;&lt;img src="/image1.gif" /&gt;&lt;/a&gt;&lt;/textarea&gt;
  &lt;textarea&gt;&lt;a href="/"&gt;&lt;img src="/image2.gif" /&gt;&lt;/a&gt;&lt;/textarea&gt;
  &lt;textarea&gt;&lt;a href="/"&gt;&lt;img src="/image2.gif" /&gt;&lt;/a&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>And with jQuery I am trying to replace the href and src values (the src initial value must preserve) with regexp converting it into these:</p>
  
  <pre><code>&lt;textarea&gt;&lt;a href="http://www.sitename.com"&gt;&lt;img src="http://www.sitename.com/image1.gif" /&gt;&lt;/a&gt;&lt;/textarea&gt; // see how we preserve the original src value by just adding the sitename
  &lt;textarea&gt;&lt;a href="http://www.sitename.com"&gt;&lt;img src="http://www.sitename.com/image2.gif" /&gt;&lt;/a&gt;&lt;/textarea&gt;
  &lt;textarea&gt;&lt;a href="http://www.sitename.com"&gt;&lt;img src="http://www.sitename.com/image2.gif" /&gt;&lt;/a&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>I figured out that with the following regexp <code>(?&lt;=href=(\"|'))[^\"']+(?=(\"|'))</code> and <code>(?&lt;=src=(\"|'))[^\"']+(?=(\"|'))</code> I can locate the values but the rest have no idea...</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>$(function(){
          (function(){
              $('textarea').each(function(){
                  var obj = $(this);
                  obj.text().replace(REGEXP,"http://www.sitename.com/);  //by placing the above regexp the script wont work
  
                  //missing the src part
  
              });
          })();
      });
  </code></pre>
  
  <p>any help is appreciated </p>