From: Sam Kong Date: 2006-08-12T09:54:04+09:00 Subject: String#split(/\s+/) vs. String#split(/(\s+)/) Hello Rubyists, I'm reading Ruby Cookbook. The first chapter is about String. One of the examples shows the differenct between String#split(/\s+/) and String#split(/(\s+)/) without much explanation. I understand what sub-grouping is in regex. Bug I don't understand what role that plays in String#split. s = "one two three" p s.split(/\s+/) #=> ["one", "two", "three"] p s.split(/(\s+)/) #=> ["one", " ", "two", " ", "three"] Could anybody explain it, please? Thanks, Sam -- Posted via http://www.ruby-forum.com/.