I have a string that would have a similar pattern as $string below (pulled from forum posts).
$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;
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).
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.
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.
.
NOTE: I tried both codes provided by drew010 and bsdnoobz (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:
$string = '[quote="abc123":27zslwh3]I dont agree with most of the statements made here.
abc123[/quote:27zslwh3]
I dont think that is very nice of you.';
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.