From: Gennady Bystritsky Date: 2006-01-17T16:47:58+09:00 Subject: Re: Question about regular expression ------_=_NextPart_001_01C61B3A.4C7C2A57 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ^ means from the beginning of a line ($ - end of line). * means that a preceding character or group may be repeated 0 or more = times. Gennady. -----Original Message----- From: Eric Luo [mailto:eric.wenbl@gmail.com] Sent: Mon 1/16/2006 23:17 To: ruby-talk ML Subject: Re: Question about regular expression =20 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 > > > ------_=_NextPart_001_01C61B3A.4C7C2A57--