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 .)
EDIT: edited to enable newlines through a very hackish manner.
EDIT: forgot to escape the fullstops and brackets where necessary.