Regular expressions library
For the project I work on now, I needed to know if the string contained a valid dutch postcode value. Best way to do this is using a regular expression. For example:
int IsPostcode(string value)
{
Regex regex = new Regex(@"^[1-9][0-9]{3}\s?[a-zA-Z]{2}$");
Match m = regex.Match(value);
return m.Success;
}
The problem is of course finding the right expressions. For this, I now use Regular Expression Library on the internet. Most of you probably already know this web site. For those who don't, check it out. It's a really good resource for regular expression.