Reputation: 295
Do not convert
<br/>
<br/><br/>
Convert, if there are more than two newline tag
<br/><br/><br/>
into
<br/><br/>
How to add my condition to this?
preg_replace("/(<br\s*\/?>\s*)+/", "<br/><br/>", $input);
Upvotes: 0
Views: 421
Reputation: 133
Using the metacharacter {min,max}
after the regex will help you.
The wikipedia actually does a really good job, also the regex.info is really helpful.
Upvotes: 0
Reputation: 174696
I would recommend you to use \h
instead of space where \h
matches all type of horizontal spaces.
preg_replace('~(<br\h*\/?>){2,}~', '<br/><br/>', $string);
Upvotes: 0