CodePudding user response:
You can repeat matching 0-3 times including the >
using
^(?:[^>]*>){0,3}[^>]*
^
Start of string(?:[^>]*>){0,3}
Repeat 0 - 3 times matching any character except>
and then match>
[^>]*
Optionally match any char except>
See a regex demo.
If there should be at least a single >
then the quantifier can be {1,3}