From: Joel VanderWerf Date: 2006-08-25T09:12:55+09:00 Subject: Re: Determinig if 3 characters in a row are the same? 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. > irb(main):001:0> s1 = "1234aaa567" => "1234aaa567" irb(main):002:0> s2 = "1234abc567" => "1234abc567" irb(main):003:0> s1 =~ /(.)\1\1/ => 4 irb(main):004:0> s2 =~ /(.)\1\1/ => nil irb(main):005:0> -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407