Page 1 of 1

Trim between characters

Posted: Sun May 07, 2006 7:33 pm
by GeXus
Hello,

If I had the following string: Good Movie (Widescreen)

and I wanted to delete the (Widescreen), so everything inbetween the parren and including the parren.

How would I do this??

Thank you!

Posted: Sun May 07, 2006 7:57 pm
by s.dot

Code: Select all

$str = 'Good Movie (Widescreen)';
$newstr = preg_replace("#\(.*?\)#",$str);
echo $newstr;

Posted: Sun May 07, 2006 8:16 pm
by GeXus
scottayy wrote:

Code: Select all

$str = 'Good Movie (Widescreen)';
$newstr = preg_replace("#\(.*?\)#",$str);
echo $newstr;
Thanks! But I receive an error "Wrong parameter count"

Posted: Mon May 08, 2006 12:57 am
by dibyendrah
Missing one parameters :

Code: Select all

<?php
$str = 'Good Movie (Widescreen)';
$newstr = preg_replace("#\(.*?\)#", "", $str);
echo $newstr;
?>