title: Jquery Javascript Replace String
body: <p>The wysiwyg editor I'm using uses this to replace the <code>&lt;strong&gt;</code> with a span style.  I modified to add a code block. </p>
  
  <pre><code>v=v.replace(/&lt;strong&gt;(.*)&lt;\/strong&gt;/gi,'&lt;span style="font-weight: bold;"&gt;$1&lt;/span&gt;');
  </code></pre>
  
  <p>This works fine until I highlight code with <p></p> <b></b></p>
  
  <pre><code>v=v.replace(/&lt;pre&gt;(.*)&lt;\/pre&gt;/gi,'&lt;div id="precode"&gt; $1 &lt;/div&gt;');
  </code></pre>
  
  <p>I have been looking and can't fine any info on replace. Can someone explain </p>
  
  <p>Can someone explain this part of the code? I'm sure it will help others as well</p>
  
  <pre><code>.replace(/&lt;strong&gt;(.*)&lt;\/strong&gt;/gi,'
  </code></pre>
  
  <blockquote>
    <p>Is there something in this causing the it to add the new style to each
    line</p>
  </blockquote>
  
  <pre><code>if(id=='style'){
                  var sel=document.createElement('select'),
                  styles=obj.styles||[['Style',''],['Paragraph','&lt;p&gt;'],['Header 1','&lt;h1&gt;'],['Header 2','&lt;h2&gt;'],['Header 3','&lt;h3&gt;'],['Header 4','&lt;h4&gt;'],['Header 5','&lt;h5&gt;'],['Header 6','&lt;h6&gt;'],['CodeBlock','&lt;pre&gt;']],
                  sl=styles.length, x=0;
                  sel.className='testyle'; sel.onchange=new Function(this.n+'.ddaction(this,"formatblock")');
                  for(x;x&lt;sl;x++){
                      var style=styles[x];
                      sel.options[x]=new Option(style[0],style[1])
                  }
  </code></pre>