2009/5/29 Harry Kakueki <list.push / gmail.com>:
> On Fri, May 29, 2009 at 5:48 PM, Brian Candler <b.candler / pobox.com> wrote:

>> I think you need a negative lookahead assertion.
>> * http://www.ruby-doc.org/docs/ProgrammingRuby/
>> * click on "The Ruby Language"
>> * scroll to "Extensions"
>> * look for (?!re)
>>
>> irb(main):009:0> /^(.)(?!\1)(.)(?!\1|\2)(.)(\2)$/ =~ "abcb"
>> => 0
>> irb(main):010:0> /^(.)(?!\1)(.)(?!\1|\2)(.)(\2)$/ =~ "abbb"
>> => nil

> I need to read that section carefully to be sure I understand.
> But, I think that does the trick.

The problem with this approach is that it does not work for strings of
arbitrary length.  Even if you adjust it to work for multiple lengths
you always have a fixed upper limit for which it can work.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/