/(bb|[^b]{2})/ that is the Question: Think Geek has a t-shirt for the regular expression junkie. The regular expression has actually a real function: it splits strings into groups of 2 characters, it is the same as /(\w{2})/.

"jochen".scan(/(bb|[^b]{2})/)
=> [["jo"],["ch"],["en"]]
Advertisements