Click here to Skip to main content
15,922,533 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I had Allowed Validation for two Dots coding is...

string pattern =   string pattern = @"^[a-z][a-z|0-9_\-\|]*([_][a-z|0-9]+)*([.][a-z|" +
                    @"0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*\.([a-z]" +
                    @"[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$"; 

But i have to allow 3 dots only,
please Help me sir!
Posted
Updated 30-Jan-12 22:17pm
v3
Comments
OriginalGriff 30-Jan-12 3:31am    
I'm not too shabby at regexes, and I have to agree with Expresso that that won't work: "[.]" is an invalid character class.
What are you actually trying to achieve, that you think this regex is the way to go?
Sergey Alexandrovich Kryukov 30-Jan-12 3:35am    
Agree. Maybe changing from [.] to [\.] will fix it?
--SA
OriginalGriff 30-Jan-12 3:36am    
I did think of that, but I'm not so sure what his problem actually is, so it's difficult to say.
[no name] 30-Jan-12 8:02am    
I *guess* this is what he's trying to convey: The regex is currently allowing only 2 dots in the email ID. And he needs to change it to allow 3 dots. :)

Although, the regex looks quite shabby and I'm clueless where to correct! :)
BillWoodruff 30-Jan-12 22:12pm    
I wonder why you are using three dots here, since, in Windows programming user interfaces, that has been used for a long time in certain ways. Although, technically what is being referred to here :

http://en.wikipedia.org/wiki/Ellipsis#Computer_interfaces_and_programming

Is the ellipsis character, not three dots.

1 solution

C#
public static bool ValidateEmail(string StreMail)
        {
            if (StreMail.Length == 0) return true;
            System.Text.RegularExpressions.Regex rEmail = new System.Text.RegularExpressions.Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
            if (rEmail.IsMatch(StreMail)) return true;
            return false;
        } 
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900