From: Brian Candler Date: 2012-05-01T02:11:23+09:00 Subject: Re: delete character from array Chris Morris wrote in post #1058975: > This is a little blunt, but may be what you need: > > '123123123123'.scan(/(\w\w)\w/).to_s > => "12121212" That doesn't delete every third character in the string though, as a couple of simple tests will show: >> a = "abcd" => "abcd" >> a.scan(/(\w\w)\w/).to_s => "ab" >> a = "the quick brown fox jumps over the lazy dog" => "the quick brown fox jumps over the lazy dog" >> a.scan(/(\w\w)\w/).to_s => "thqubrfojuovthlado" This is closer: >> a.scan(/(..)./m).to_s => "th qic bow fx ums ve te az d" But you can see it's still not right, as it's lost the final "g". I think this is right: >> a.gsub(/(..)./m) { $1 } => "th qic bow fx ums ve te az dg" Here is another way: >> a.chars.enum_slice(3).map { |x| x[0,2] }.join => "th qic bow fx ums ve te az dg" -- Posted via http://www.ruby-forum.com/.