From: James Edward Gray II Date: 2006-01-17T11:41:44+09:00 Subject: Re: Question about regular expression On Jan 16, 2006, at 8:35 PM, Eric Luo wrote: > I need to hack out an regular expression, which will match "SNPB" > without > matching "STR SNPB". > Since ruby 1.8.2 or 1.8.4 don't support the lookbehind feature. > what's the > workable regular expression > for ruby version 1.8.2? Lookbehind is just lookahead, backwards. ;) >> tests = %w{SNPB STR\ SNPB} => ["SNPB", "STR SNPB"] >> tests.map { |t| t.reverse }.grep(/\bBPNS\b(?! RTS)/).map { |t| t.reverse } => ["SNPB"] Hope that helps. James Edward Gray II