Morton Goldberg
8/25/2006 1:13:00 AM
Here is a minor variation that's good to keep in mind should you ever
need find a lot more than 3 chars in row. Saves typing a whole lot of
'\1's.
# Find 8 of the same char in a row
/(.)\1{7}/ =~ 'zyzyzxxxxxxxxzyzyz'
p $& #=> "xxxxxxxx"
/(.)\1{7}/ =~ 'zyzyzxxxxxxzyzyz'
p $& #=> nil
Regards, Morton
On Aug 24, 2006, at 8:02 PM, Ben Johnson wrote:
> Sorry for the noob question, but is there a fast and efficient way to
> determine if there are 3 of the same charater in a row in a string?
> I'm
> sure this could be done in regex but I am not a black belt in regex.
>
> thanks for your help.