PHP Regex修剪文件

I need to go through a huge file and remove all strings that appear within <> and (. .).

Between those brackets there can be anything: text, numbers, whitespaces etc.

Eg: < there will be some random 123 text here >

I could read the file and use str_replace to trim out all those parts, but what I don't know is how can I use regex to pick up the string enclosed in the brackets.

Here's what I want to do:

$line = "this should stay <this should not>";
//$trim = do something here using regex so $trim = "<this should not>"

$line = str_replace($trim,"",$line);

PS: The data might be spread across lines:

this should stay 
(. this
should
not .)
$nlstr = "{{{".uniqid()."}}}"
$str = str_replace("
",$nlstr,$str);
$str = preg_replace("/<[^>]*>/","",$str);
$str = preg_replace("/\(\.([^.)]+[.)]?)*\.\)/","",$str);
$str = str_replace($nlstr,"
",$str);

EDIT: edited to enable newlines through a very hackish manner.
EDIT: forgot to escape the fullstops and brackets where necessary.

If you don't have to worry about nesting (\(\..*?\.\))|(<(.*?>) will do the job

Use the non-greedy quantifier .*? to match a < with the closest >. Use the s modifier to take care of newlines within your string:

<?php
$str = 'this should stay < this should not >
this should stay (.this should not.)
this should stay < this
should
not >
this should stay (.this 
should 
not.)';
$str = preg_replace('@<.*?>@s', '', $str);
$str = preg_replace('@\(\..*?\.\)@s', '', $str);
echo $str;
?>

Output:

this should stay 
this should stay 
this should stay 
this should stay