From: Hassan Schroeder Date: 2010-11-14T04:22:20+09:00 Subject: Re: Very simple regex question On Sat, Nov 13, 2010 at 11:06 AM, Geometric Patterns wrote: > I don't understand why the regex in the example below isn't identifying > that the string is longer than 12 characters long... >>> if line =~ /[a-zA-Z]{2,12}/ That succeeds if the string *contains* between 2 and 12 characters, not if it consists solely of 2-12 characters. line = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" if line =~ /[a-zA-Z]{2,12}/ puts "good" # you'll get this else puts "bad" end if line =~ /\A[a-zA-Z]{2,12}\Z/ puts "good" else puts "bad" # you'll get this end FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com twitter: @hassan