Li Chen wrote: >> 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 You're so close. seq="5'aaaAAAAAACCCCCCCCTTTTTTTGGGGGGGGG-3'" seq.upcase!# change to upper case puts "old sequence:" puts seq.gsub!(/[^A-Z]/,'')# extract the string puts position = seq=~/AC/ #The counting starts at zero. Or use the more simple but less powerfull puts position = seq.index("AC") regards, Siep -- Posted via http://www.ruby-forum.com/.