From: Joel VanderWerf Date: 2010-11-11T11:33:26+09:00 Subject: Re: Total string length regex On 11/10/2010 06:04 PM, Shea Barton wrote: > How would I limit the total string length for this regex to be between x > and y characters? You could use this approach: >> rx = /^(?=.{5,10}$)\w+$/ => /^(?=.{5,10}$)\w+$/ >> rx =~ "foo" => nil >> rx =~ "foo!bar" => nil >> rx =~ "fooibar" => 0 >> rx =~ "fooibarbazwhupple" => nil