snappyco.de

rss

Fixing C# - Part II

This is part 2 of my series on making c# a nice language to work with. Previously I gave you flexible string quotation, today I present:

Regular Expressions as native types

Ever written code like this?

var money = Regex.Replace(@" $ 1,337", @"[\$\s\,]", "");

Regular expressions are so important to programming that they should be catered for in the language. At least Ruby and Javascript agree with me.

If c# understood regular expressions as a native type, we could have code like this:

var money = @" $ 1,337".Replace(/[\$\s\,]/, "")

You can instantly spot the regex, it doesn't have to be @ encoded into a string. We can also then have a replace method overload that takes a string or a regex type without any new Regex() bs.

I'm a sydney based software developer. I currently build stuff with ruby, c# and objective-c.

dave@snappyco.de

I'm on Twitter

  • Thanks japan, now I REALLY hate Sydney trains. 9 minute wait?!
  • Drugs are bad mmmkay http://bit.ly/9Jl7v1
  • NSCoders: [[NSArray arrayWithObjects:...] retain] or [[NSArray alloc] initWithObjects:...]
  • Anyone wanna give me a desk to work at today in surry hills?
  • Back in oz after a wicked japan #rubykaigi trip. Domo arigato japan!

I'm on Github