Background for Question
I'm using Ruby 3.2.1, and I know that changes have been made to Ruby's regexp engine. That may or may not be relevant here. However, I get unexpectedly different behavior from String#match and String#scan when using backreferences, and I don't understand why. See example code below.
My Examples, with Comments and Expectations
Working Result with Match
# Using #match finds the longest string of
# repeated letters, and the letter that is
# repeated.
"gjhfgfcttttdfs".match /(\p{alpha})\1{2,}/
=> #<MatchData "tttt" 1:"t">
Non-Working, Unexpected Result with Scan
# Here, #scan returns only a single sub-
# array with a single letter, which is
# the correct letter. However, I was
# expecting an array-of-arrays with all
# repeated letters.
"gjhfgfcttttdfs".scan /(\p{alpha})\1{2,}/
=> [["t"]]
Clarifying the Question
Assuming the problem exists between the keyboard and chair, why is String#scan not returning more matches, or even a single longer match? I'm assuming it's a mistake on my part in the capture expression, but I can't really figure out what I did wrong here.
Seems a little vague, but I think it's been this way for a long time.
To get the whole match, you can capture it, to be part of
scanresults:Full match is only available from the
scanblock: