From: shaman Date: 2008-07-03T19:22:00+09:00 Subject: Re: yet another regexp problem Srijayanth Sridhar pisze: > /([a-z]{3})[02-9][0-9]{2}\1/ > > Should work. > irb(main):008:0> m > => /([a-z]{3})[02-9][0-9]{2}\1/ > irb(main):009:0> a='xxx765xxx' > => "xxx765xxx" > irb(main):010:0> b='vvv123vvv' > => "vvv123vvv" > irb(main):011:0> a.match(m) > => # > irb(main):012:0> puts a.match(m) > xxx765xxx > => nil > irb(main):013:0> puts b.match(m) > nil > => nil > it's not so easy because "vvv133vvv" also should match but your expression return nil :( irb(main):001:0> reg = /([a-z]{3})[02-9][0-9]{2}\1/ => /([a-z]{3})[02-9][0-9]{2}\1/ irb(main):002:0> a = "vvv123xxx" => "vvv123xxx" irb(main):003:0> puts a.match(reg) nil => nil irb(main):004:0> b = "vvv133xxx" => "vvv133xxx" irb(main):005:0> puts b.match(reg) nil => nil numer 123 is the only one should not match.