From: Sebastian Hungerecker Date: 2008-01-11T21:28:43+09:00 Subject: Re: search pattern Li Chen wrote: > Stefano Crocco wrote: > > String=~ returns the position of the starting of the match, so > > > > seq=~pattern > > > > will return what you want. > > The size if seq is 33. What I try to do is starting position of "AC" in > the seq. > > How do I calculate the position of it? For some reason I have the Jeopardy melody in my head now... Anyway: >> seq="AACGTGTAGGCTTGAAA" => "AACGTGTAGGCTTGAAA" >> pattern = /TA/ => TA >> position = seq =~ pattern => 6 >> seq[position,2] => "TA" >> seq[position..-1] => "TAGGCTTGAAA" >> seq[pattern] => "TA" HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826