On 02.02.2007 05:26, Chris Shea wrote: > Word wrapping is wrong for the occasion, as I'd like to split even > lines less than 20 chars, and have them of approximately equal length. If you want to first fill the first string and then the second you can do this: first, second = s.scan /.{1,20}/ For evenly distribution you could do: irb(main):019:0> s="foo bar ajd as dashd kah sdhakjshd ahdk ahsd asjh" => "foo bar ajd as dashd kah sdhakjshd ahdk ahsd asjh" irb(main):020:0> l=[40,s.length].min / 2 => 20 irb(main):021:0> first = s[0...l] => "foo bar ajd as dashd" irb(main):022:0> second = s[l...l+l] => " kah sdhakjshd ahdk " If you want to break at white space, you can do it with one regexp (you did ask for the one regexp solution :-)): irb(main):030:0> s="aasd laksjd asdj asjkd asdj jlas d" => "aasd laksjd asdj asjkd asdj jlas d" irb(main):031:0> %r[(.{1,#{s.length/2}})\s*(.{1,#{s.length/2}})] =~ s or raise "cannot split" => 0 irb(main):032:0> first = $1 => "aasd laksjd asdj" irb(main):033:0> second = $2 => "asjkd asdj jlas d" Kind regards robert