Doable with a simple regex: aaaabbbbzzxxxhhnnppp'. Scan(/((.)\2*)/). Map{|x| x0} => "aaaa", "bbbb", "zz", "xxx", "hh", "nn", "ppp".
Doable with a simple regex: 'aaaabbbbzzxxxhhnnppp'. Scan(/((.)\2*)/). Map{|x| x0} => "aaaa", "bbbb", "zz", "xxx", "hh", "nn", "ppp".
1 The outer parentheses are necessary for Ruby's String#scan to keep the results in the output; the inner parentheses are necessary to capture the single character so that it may be referenced by \2. You could also write this in Ruby 1.9 as str. Scan(/((.)\2*)/).
Map(&:first) – Phrogz Jan 24 at 2:13.
What I am trying to figure out is how to split a string when the next character doesn't match the previous and pass the groupings into an array. I know I could just iterate over each char in the string and check for a change but am curious if there's anything built-in that could tackle this in a elegant manner.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.