In article <238b37f9-2df1-42b8-b821-dbb6c24a9d9e / s8g2000prg.googlegroups.com>, crm_114 / mac.com writes: > For the following string: > > 'cat sheep horse cat tac dog' > > I would like to write a regular expression that matches any substring > that is prefixed by the word 'cat', is then followed by any characters > as long as those characters do not comprise the word 'cat', and then > finally suffixed by the string 'dog'. Therefore, this expression > should match the substring 'cat tac dog' in the above string. % /usr/bin/ruby -e 'p /cat((?!cat).)*dog/.match("cat sheep horse cat tac dog").to_s' "cat tac dog" -- Tanaka Akira