30 Mar '12, 7pm

This came up again today: gsub can take a block

This came up again today: gsub can take a block

September 8, 2009 Tagged: ruby Comments (View) gsub with a block Did you know gsub can take a block? I didn’t until today. "10 comments".gsub(/ (.+)/) do |words| " <div class='superstyle'>#{words.lstrip}</div>" end # "10 <div class='superstyle'>comments</div>" I like giving the match an intention-revealing name instead of $1 . However, it seems limited. I would have expected $1 to be the first block parameter, $2 to be the second block parameter, etc., but I have only been able to get one block variable.

Full article: http://robots.thoughtbot.com/post/183070874/gsub-with-a-b...

Tweets

China microblogs block users from posting comments

channelnewsasia.com 31 Mar '12, 3am

BEIJING: China's two most popular microblogs, Sina Weibo and Tencent QQ, on Saturday blocked web users from posting commen...

Hard

A lot of endurance athletes, particularly women, struggle with low iron. As a new study in the International Journal of Sp...

New blogger on the block

anilnetto.com 03 Apr '12, 6pm

A long awaited entry into blogosphere: you would have seen his writings all over the place including his contributions to ...

Google: Don't Block Your CSS & JavaScript Files

seroundtable.com 27 Mar '12, 12pm

Yesterday, Google's Matt Cutts posted a video as a "public service announcement" asking SEOs and webmasters who are blocki...

If you're struggling with low iron levels, read...

A lot of endurance athletes, particularly women, struggle with low iron. As a new study in the International Journal of Sp...