Hi -- On Thu, 27 Jan 2005, Assaph Mehr wrote: > > Jeff Davis wrote: >> In python the regexes allow you to call a function instead of just >> substitute the values (see <http://docs.python.org/lib/node111.html> > for >> more details). That seems quite useful, is there something similar in > ruby? >> >> Also, let's say I want match anything between "a" and "b" unless it >> contains the word "foo". I could write two regexes like so: >> >> if str =~ /a(.*)b/ and str !~ /a(.*foo.*)b/ >> >> Is there a good way to make that kind of logic into one regex? Is > there >> some kind of "intersect" operator or a "not" operator? > > > You can't write executable code within the regex, but... I don't think it will help Jeff's case, but in general you certainly can include code in a regex if you want to: irb(main):001:0> puts "match" if /abc#{gets.chomp}/.match("abcdef") def match David -- David A. Black dblack / wobblini.net