From: Mark Bush Date: 2008-02-23T05:12:48+09:00 Subject: Re: Regex in Ruby question ThoML wrote: > There are of course situations when this isn't possible. require 'strscan' # 0 1 2 3 # 0123456789012345678901234567890123456789 s = StringScanner.new('obar blabar oofbar foobar ofobar offbar') # ^ ^ ^ ^ until s.eos? m = s.scan_until(/([^o]|[^o]o|[^f]oo)(bar)/) p s.pos end # => 11 18 32 39 :-( However, with: m = s.scan_until(/(([^o]|^)|([^o]|^)o|([^f]|^)oo)(bar)/) => 4 11 18 32 39 :-) -- Posted via http://www.ruby-forum.com/.