Hi All,

I have this function that I'm using to preview a forum post. I'm trying to get it to remove the Break tags WITHIN the code blocks and not BETWEEN the code blocks and cant seem to find the right RegExp expression to do it. As you can see I'm converting the code blocks into a textarea input field much like it does here at Sitepoint but when someone presses the "enter/return" key a break tag is inserted that when rendered might be confusing to the poster when they preview the post. I'm a Classic ASP developer and only have a little experience with javascript, could someone please help?

Code:
function preview (id){
 //var text = document.reply.message.value;
var text = "['code]Some Code['/code]<BR>['code]Some<BR>More<BR>Code['/code]";
 text = String(text);
 var patt1 = new RegExp(/((\[code\])*(\<BR\>)*(\[\/code\])*)*/g);
 
  if(document.getElementById(id).style.display =='none'){ 
   document.getElementById(id).style.display ='inline';
  var result = patt1.test(text);
  if (result == true){
   //text = text.match(patt1);
      text = String(text);
   text = text.replace(/\B\<BR\>/g,"");
   text = text.replace(/\[code\]/g,"<textarea rows=5 cols=20>");
   text = text.replace(/\[\/code\]/g,"</textarea>");
   text = text.replace(/\,/,"<br />");
  }
  else{
    text = text.replace(/\[code\]/g,"<textarea rows=5 cols=20>");
    text = text.replace(/\[\/code\]/g,"</textarea>");
   text = text.replace(/\B\<BR\>/g,"");
   text = text.replace(/\,/,"<br />");
  }
  document.getElementById(id).innerHTML = text;
 }
 else {
   document.getElementById(id).style.display = 'none';
 }
}
Note: I had to add single quote marks in the "code" tags of the text string to avoid sitepoint rendering them as textarea boxes.

tia