I want to use a negative look-ahead inside a non capturing group in Perl Regex. So far i have create an expression that not allows 3 "pairs of characters" into a string
CASE 1: ^(?!(?:\w*(.)\1){3}).+$
For example the string: Mytte!3sttStrring | Not pass - 3 pairs | "tt","tt","rr"
If you see there is a negative look-ahead before the group, i want to add this expression into a group. To understand this i will present you an other example that disallows only one pair or chars.
CASE 2 : no match if there is a pair in string: (?=^(?:(.)(?!\1))*$)
If you test these 2 expressions in https://regex101.com/ you will see that for the string "MySampleString" on the CASE 2 I have 2 Match Information. (Full Match and Group 1 Match). Now if you run the first pattern (CASE 1) you will see only the Full Match at Match Information.
In my try add grouping match option in the CASE 1 putting brackets around:
CASE 1 my try: (^(?!(?:\w*(.)\1){3}).+$)
but now the expression inside doesn't work :/
I want to find a way that ^(?!(?:\w*(.)\1){3}).+$ will work (with Full Match and Group1 Match). I have to add this option to a very long regular expression that I'm working on and it cant work as a full match group. To make it cleaner i will show you an example that the String must not have a "pair of chars" and at the same time not to include 4 repetitions of any letter.
(?=^(?:(.)(?!\1))*$)(?=^(?:(.)(?!(?:.*?\1){4}))*$)
These 2 expressions (?=^(?:(.)(?!\1))$) and (?=^(?:(.)(?!(?:.?\1){4}))*$) combined because both have a grouping match.