i need to wipe all content inside brackets including the brackets from a string to process it for my search-engine
my regex so far is :
'/[\[{].*[\]}]/U'
this works pretty good but it doesnt work if there is a linebreak inside the brackets
here is an example ( and it took me a lot of time to narrow down to the * linebreak...):
echo preg_replace('/[\[{].*[\]}]/U', ' ', strip_tags('<h1> how can i </h1>
[portfolioitem img="/fooobarbaoarbaororboabro.jpg" alt="fooobarbaoarbaororboabro" url="fooobarbaoarbaororboabro/" imglink="Lebenslauf »" description="fooobarbaoarbaororboabro" headline="fooobarbaoarbaororboabro" link="Lebenslauf »"]
[/span][span size="6"]
<h1> wipe this away?</h1>
[portfolioitem img="fooobarbaoarbaororboabro.jpg" alt="fooobarbaoarbaororboabro" url="/fooobarbaoarbaororboabro/" imglink="foo" description="foo foo foo
bar foo foo bar foo" headline="fooo" link="Lebenslauf "]
'));
as you can see, there is a linebreak in the second "[portfolioitem..." and for some reason this outputs :
how can i
wipe this away?
[portfolioitem img="fooobarbaoarbaororboabro.jpg" alt="fooobarbaoarbaororboabro" url="/fooobarbaoarbaororboabro/" imglink="foo" description="foo foo foo
bar foo foo bar foo" headline="fooo" link="Lebenslauf "]
i dont get any further and im not regex pro enough can someone please help me make my regex " ewline insensitive" ?!
thanks in advance for any help !
You need to use s
(DOTALL) flag in your regex to make dot
match new lines. Try this regex:
/[\[{].*?[\]}]/Us