Verbose Logging

software development with some really amazing hair

T + S G I F R

Ruby Regex For Fun And Profit

· · Posted in Programming
Tagged with

Regex are always fun, and since regex expressions are first class citizens in ruby, it makes it so much easier.

I found this Code Golf question on Stackoverflow and threw together a quick method to do it. I can't take all the credit, since I needed to search a bit to figure out if I could do matching parenthesis in ruby, and found that I could, but only in ruby 1.9, which ruby forum topic showed me. Then a commenter on SO pointed out another optimization. I also used rubular to help me with the little regex things to get the other regex just right.

Check out my answer here

Oh yeah, and vote that thing up! It's ruby 1.9 for crying out loud! :D

Sharing is Caring