From: Mike Stok Date: 2005-12-25T13:06:33+09:00 Subject: Re: Regex: how to match duplicate syllables? On 24-Dec-05, at 10:27 PM, basi wrote: > Merry Christmas! > > But work goes on :( > > Just trying a way to match duplicate syllables. > > C = "bcdfghjklmnpqrstvwxyz" > V = "aeiou" > > aString =~ /[#{C}][#{V}][#{C}][#{V}]/ > > should match if the first CV matches the next CV. Hence, "waikiki" > should match on "kiki". And "dodo", "paparazzi" should match too. What about using \1 e.g. C = "bcdfghjklmnpqrstvwxyz" V = "aeiou" %w{ kiki dodo paparazzi abacab }.each do |word| puts "#{word} matched" if word =~ /([#{C}][#{V}])\1/ end Hope this helps, Mike -- Mike Stok http://www.stok.co.uk/~mike/ The "`Stok' disclaimers" apply.