REGEX - Matching any character which repeats n times
问题 How to match any character which repeats n times? Example: for input: abcdbcdcdd for n=1: .......... for n=2: ......... for n=3: .. ..... for n=4: . . .. for n=5: no matches After several hours my best is this expression (\w)(?=(?:.*\1){n-1,}) //where n is variable which uses lookahead. However the problem with this expression is this: for input: abcdbcdcdd for n=1 .......... for n=2 ... .. . for n=3 .. . for n=4 . for n=5 no matches As you can see, when lookahead matches for a character, let