Skip to content
Advertisement

(REGEX) Replace with empty when two appear in a string PHP

i have differents strings may be can:

1 Case

JavaScript

2 Case

JavaScript

3 Case

JavaScript

I’m try to limit to

JavaScript

In cases if have found 3 or more continue

JavaScript

With the php code:

JavaScript

Expected cases:

1 Case

JavaScript

2 Case

JavaScript

3 Case

JavaScript

Used regex:

JavaScript

Testing: https://paiza.io/projects/sLcZE5fW99p3gfrxaZGDsg

Thanks

My Regex not working

Advertisement

Answer

If you want to replace three or more <br> tags with just two tags, then use:

JavaScript

This prints:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement