• behance
  • gitHub
  • google
  • linkedin
  • twitter
C# Regular Expressions

C# Regular Expressions

I’ve recently found the need to really optimise some C# code using regular expressions instead of using multiple statements to tidy up strings before processing the contents of those strings. Regular Expressions can really take some getting used too and certainly require time to really master to any degree. What is a Regular Expression? Here is a line of C# that will illustrate how to remove all the numbers held within a string:

[source:c-sharp]Regex regEx = new Regex(“[0-9]”);
stringtoclean = regEx.Replace(stringtoclean, “”);
[/source]

During my brief look into using Regular Expressions I found a really neat tool called Expresso which is free to download and you can grab it here:

http://www.ultrapico.com/Expresso.htm

Leave a reply

*