View Single Post
  #1 (permalink)  
Old December 21st, 2011, 01:57 PM
hozdaman hozdaman is offline
Authorized User
Points: 221, Level: 4
Points: 221, Level: 4 Points: 221, Level: 4 Points: 221, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
Default Chapter 4:Reusable function

Hi,

First I would like to say I really like this book. Thanks.

I am having trouble with the reusable function. The email address is coming out false everything looks okay to me.

Code:
@using System.Text.RegularExpressions;

@functions {
    public static bool IsValidEmail(string s)
    {
        string pattern = @"^[\w-\.]+@ ([\w-]+\.)+[\w-]{2,4}$";
        return Regex.IsMatch(s,pattern);
    }
}
Please help. Thanks.
Reply With Quote