如何在php中将两个以上的标签转换为双色<br/> <br/>

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);
(<br[ ]*\/?>){2,}

Simply use this.And replace it by <br/><br/>.

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.

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);