Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

str_replace 1

Status
Not open for further replies.

bccamp

Technical User
Jan 20, 2005
69
I'm trying to remove text between '( )' using str_replace, preg_replace, or anything that will work, but I don't know how to code for 'everything in the middle'. ex.
Code:
Hello World (stuff in here)
I want to remove '(stuff in here)' including parenths. I've looked at the man pages, but either I'm stupid....or I'm stupid b/c I don't understand process.
 
something like
Code:
<?
$text = "Hello World (I am in brackets)";
$pattern = '/(\(.*?\))/i';
$replace = '';
$newtext = preg_replace($pattern, $replace, $text);
echo $newtext;
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top