suprabha r. wrote in post #1011335: > hi > its a simple question yet google wasnt of much help > > string = a_b_c_d_e > > search results mostly show how to split it as a b c d e > > but how to split it as a_b and c_d_e ? Well, one obvious way is to split it into ["a","b","c","d","e"] as google showed, select the bits you want, then join them back together again. Look at Array#join. ["a","b"].join("_") # => "a_b" Another way is to use a regular expression to match the patterns you're looking for. e.g. if string =~ /\A([^_]*_[^_]*)_(.*)\z/ str1, str2 = $1, $2 else raise "Unexpected format" end There are many resources on ruby regular expressions you can google for. -- Posted via http://www.ruby-forum.com/.