title: PHP preg_replace text between two strings
body: <p>I have a string that would have a similar pattern as $string below (pulled from forum posts).</p>
  
  <pre><code>$string = "[quote=\"abc123\":27zslwh3]I don't agree with most of the statements made here.[/quote:27zslwh3] I don't think that is very nice of you.";
  $pattern = "/\[quote\=.\*\[\/quote.*\]/";
  $replace = "";
  
  $updated_text = preg_replace($pattern,$replace,$string);
  echo $updated_text;
  </code></pre>
  
  <p>I am trying to use preg_replace to remove all the text between the opening and closing [quote] tags and echo the remaining string: "I don't think that is very nice of you." only (from $string above).</p>
  
  <p>The pattern I am using for the regular expression is supposed to look for the beginning of the opening [quote] tag, then search through until it finds the closing [quote] tag and the final ] of the tag.</p>
  
  <p>The above doesn't seem to work properly though and I am not too proficient with reg expressions so am stuck here.  Any help would be appreciated.</p>
  
  <p><strong>.</strong></p>
  
  <p><strong>NOTE:</strong> I tried both codes provided by <strong>drew010</strong> and <strong>bsdnoobz</strong> (thanks for the code and explanations)
  and it still didn't work.  The issue is that I did not capture the $string text correctly.  It should read as:</p>
  
  <pre><code>$string = '[quote=&amp;quot;abc123&amp;quot;:27zslwh3]I dont agree with most of the statements made here.
  
  abc123[/quote:27zslwh3]
  I dont think that is very nice of you.';
  </code></pre>
  
  <p>there are html chars for the double quotes and what appears to be either new line or carriage return characters as well which is probably what prevented the regular expressions submitted below not work for me.</p>