We use this fancy (not really) method at Loudpixel that allows us to create dynamic stylesheets (not using a framework, just creating application.css.erb) in order to apply certain styles (mainly colors and images) to specific areas of our layouts. In order to do this we want to use a company’s name as a css rule.
When I initially implemented this I just down-cased the company name, which worked for the brand I was testing with so I moved on. Shortly thereafter I noticed some errors showing up in our dynamic stylesheet, why, well because not every company’s name is one word, with no apostrophes or any other foreign characters!
So in order to solve this issue, I slapped in a simple REGEX that removes all non-alphanumeric characters from the company’s name AND downcases it – perfect for css rules!
This really has many uses when you consider file names, URLs, CSS rules, and markup classes and ID’s.