From: Eric Luo Date: 2006-01-17T16:17:27+09:00 Subject: Re: Question about regular expression ------=_Part_7521_27313026.1137482234873 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Thanks very much, I really appreatiate your help It does work, but I couldn't figure out what the ^ and * do? could you explain that in more detail? Thanks 2006/1/17, ara.t.howard@noaa.gov : > > 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 > > (? > harp:~ > cat a.rb > strings =3D "STR SNPB", "STR", "SNPB" > > re =3D %r/^ (?: (?:[^S]) | (?:S[^T]) | (?:ST[^R]) )* SNPB /ox > > strings.each do |string| > permutations =3D 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 > matches > matches > matches > 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 > > > ------=_Part_7521_27313026.1137482234873--