Live and Learn

From the archive — written 16 years ago. About old posts.

Well, from yesterday’s entry on Ruby and Joomla and such:

article_alias.gsub!(/\-{2,}/,"-")

First, I guess article_alias.gsub!(/\-+/,"-") is less noisy by three characters. I don’t know how I got into the habit of using intervals instead of quantifiers, but it’s all over the place in my scripts.

Second, just this morning, Ruby Quicktips pointed out the “squeeze” method, which would work like this:

article_alias.squeeze!("-")

Tidy!

#regex #ruby

Drop a line about this.