interclubs
asked on
Help with Regex to Catch <br> tags at beginning AND end of line
I'm using the following regex to remove leading <br> <br /> tags and whitespace, and it works fine:
How can I modify it to also remove trailing <br> <br /> tags and whitespace though?
Thanks!
$text = '<br><br>hi there <br><br>';
echo preg_replace('/^(?:<br\s*\/?>\s*)+/', '', $text);
How can I modify it to also remove trailing <br> <br /> tags and whitespace though?
Thanks!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
yeah sorry, misread the question
The + tells it to keep going and remove all of them.
The + tells it to keep going and remove all of them.
Open in new window