this is my string
$var = 'foo<ul class="foo"> test </ul>foo<ul class="bar">foo</ul><ul></ul>foo';
this is my regex
/<ul[^>]*>.*?<\/ul>/g
this is my code
$var = preg_replace('/<ul[^>]*>.*?<\/ul>/', 'bar', $var);
i want to replace all ul elements to bar so after this code my string should look like this
foo barfoo bar barfoo
It works in regex101.com perfectly, but doesn't replace anyting in php Any ideas what's wrong with my code or regex?
//edit
After answers, I tried this and worked then I realized my original string had newlines in it.
So I changed my regex to this and it works now
/<ul[^>]*>(.|\r|\n)*?<\/ul>/g
Thanks for your answers :)