Created
June 22, 2009 03:01
-
-
Save drio/133785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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