/^ start of line [^\d]{2,4} match any non-digit (chars) containing between 2 and 4 letters <([^>]+)> inside the angle brackets store the contents in $1 upto the first right angle bracket \d?\1 then check for one digit and look-ahead (?) for the text we stored in $1 (\1 is a reference to $1) $/ with nothing else til the end of the line