On Tue, 17 Jan 2006, Eric Luo wrote: > Thanks for your replay. > > To make the problem clear. > I want to only change the regular expression, but not the code to implement > this function. > Actually, the regular expression comes from a configurable table. I'll be > supposed to only have the privilege to update the table. > > So What I really want is a alternative way to in place of the regular > expression > (?<!STR )SNPB harp:~ > cat a.rb strings = "STR SNPB", "STR", "SNPB" re = %r/^ (?: (?:[^S]) | (?:S[^T]) | (?:ST[^R]) )* SNPB /ox strings.each do |string| permutations = string, "foo #{ string }", "#{ string } bar", "foo #{ string } bar" permutations.each do |permutation| puts "<#{ permutation }> matches" if re.match permutation end end harp:~ > ruby a.rb <SNPB> matches <foo SNPB> matches <SNPB bar> matches <foo SNPB bar> matches hth. -a -- strong and healthy, who thinks of sickness until it strikes like lightning? preoccupied with the world, who thinks of death, until it arrives like thunder? -- milarepa