From: Li Chen Date: 2008-01-11T07:52:50+09:00 Subject: Re: search pattern Stefano Crocco wrote: > Alle gioved狸 10 gennaio 2008, Li Chen ha scritto: >> >> >> seq="5'aaaAAAAAACCCCCCCCTTTTTTTGGGGGGGGG-3'" >> >> seq.upcase!# change to upper case >> puts "old sequence:" >> puts seq.gsub!(/[^A-Z]/,'')# extract the string >> puts pattern if seq=~/AC/ >> >> #how to get the position of pattern in the string? > > String=~ returns the position of the starting of the match, so > > seq=~pattern > > will return what you want. > > Stefano 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? Thanks, Li -- Posted via http://www.ruby-forum.com/.