...

View Full Version : Regex question



Me & I
08-03-2007, 07:45 PM
say I've the following string :


$var = '
dgdadafhbsh sfhsr hrh wsryh rsyrsy';


I want to delete the character between the quote tags

the final string should be like this :

fhbsh sfhsr hrh wsryh rsyrsy

note that this form :

[quote comment=

at the beginning of the string

kbluhm
08-03-2007, 10:57 PM
$var = preg_replace( '/\[quote[^\]]*\].*\[\/quote\]/Usi', '', $var );

Me & I
08-03-2007, 11:22 PM
$var = preg_replace( '/\[quote[^\]]*\].*\[\/quote\]/Usi', '', $var );

it didn't work :(

kbluhm
08-04-2007, 04:00 AM
Worked for me.

This code:

<?php

$var = '
dgdadafhbsh sfhsr hrh wsryh rsyrsy';

$var = preg_replace( '/\[quote[^\]]*\].*\[\/quote\]/Usi', '', $var );

echo $var;

?>

Outputs:

fhbsh sfhsr hrh wsryh rsyrsy



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum