开发者

Using preg_replace in php for whitespace between <br/> and <p> tags

开发者 https://www.devze.com 2022-12-24 02:07 出处:网络
I need to remove this string if found in my string: <p><br/></p> Cant replace this: <p开发者_运维问答><br/>Test.</p>

I need to remove this string if found in my string:

<p><br/>   </p>

Cant replace this:

<p开发者_运维问答><br/>Test.   </p>

The whitespace expression I am using wasn't working for that, thank you for your help!


Here you go:

preg_replace('!<br/>\s+</p>!', '<br/></p>', $variable_name);


Try this:

preg_replace('%<p><br/>\s*</p>%', '', $string);

But what do you mean with Cant replace this ? Should this line also be replaced or not or how?

Update:
To clarify: Do you want to have only whitespaces removed or the whole <p><br/> </p> ?

0

精彩评论

暂无评论...
验证码 换一张
取 消