> By the way, may I know that is there any function like e.g. > left(line, > 3), right(line, 2) and mid(line, 1, 4) to extract letter from a line, > please? > e.g. > mid(gghhii,3,2) return hh > left(gghhii,3) return ggh > right(gghhii,3) return hii Remember that arrays and strings start at index 0, not index 1. str = "gghhii" p str[ 0, 3 ] #=> "ggh" p str[ -3, 3 ] #=> "hii" p str[ 2, 2 ] #=> "hh" class String def left( chars ) self[ 0, chars ] end def right( chars ) self[ -chars, chars ] end def mid( start, chars ) self[ start, chars ] end end p str.left( 3 ) #=> "ggh" p str.right( 3 ) #=> "hii" p str.mid( 2, 2 ) #=> "hh" For more ways to manipulate strings, please type "ri String" into your prompt.