Skip to content

Instantly share code, notes, and snippets.

@drio
Created June 22, 2009 03:01
Show Gist options
  • Save drio/133785 to your computer and use it in GitHub Desktop.
Save drio/133785 to your computer and use it in GitHub Desktop.
DATA.each do |line|
i = 0
# For each match of "any character followed by the same character" do:
marked = line.gsub(/(.)\1/) do |match|
i += 1
# return the match surrounded by asterisks from the block, which will
# tell gsub to replace the match with that
"*#{ match }*"
end
puts "{#{ i }} #{marked}"
end
__END__
test. AA. I greatXXrr love it.
audi tt uuuu yes.
stop here, axmmen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment