Question

I must remove from

[quote='Joker' pid='478' dateline='1346752283']
Benvenuto N1xx1, ti auguro una buona permanenza!
[/quote]Grazie.

everything is inside [quote= ...] * [/quote] and return only "Grazie."

I was returning a MyBB message but I don't need any type of [quote][/quote]

Was it helpful?

Solution

#\[[Qq]uote=(.*?)\[/[Qq]uote\]#s would match it.

$newString = preg_replace('#\[[Qq]uote=(.*?)\[/[Qq]uote\]#s', '', $yourString); Should replace them all with ''.

(Unless there are nested quotes - but that's an entirely different issue from your current question.)

OTHER TIPS

Try this

<?php
    $string = "[quote='Joker' pid='478' dateline='1346752283']          
    Benvenuto N1xx1, ti auguro una buona permanenza!            
    [/quote]Grazie.";
    echo preg_replace('/\[quote.*?\].*\[\/quote\]/si','',$string);
    echo "<hr>".preg_replace('/\[.*\]/', "", $string);

Working sample: http://codepad.viper-7.com/9n4eii

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top