Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RegularExpression for filtering unwanted e-mail address

Reply
Thread Tools

RegularExpression for filtering unwanted e-mail address

 
 
Sjaakie
Guest
Posts: n/a
 
      09-12-2006
Not sure if I this belongs in this group or a Regex-group, but since it
involves a WebControl I'll give it a try here.

I want to block hotmail, yahoo and gmail addresses when typed into a
TextBox control. Figured this could be done using a
RegularExpressionValidator control, but I can't compose a valid
expression to achieve this. Maybe you can help me out?

I used the standard e-mail validation expression, and tried to alter it
to filter Hotmail addresses. The expression below is incorrect...

\w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*

TIA
 
Reply With Quote
 
 
 
 
raghav
Guest
Posts: n/a
 
      09-12-2006
Hiii

<asp:RegularExpressionValidator
id="xyz" runat="server"
ErrorMessage="Message."

ValidationExpression="^(([a-zA-Z]|(\\{2}\w+)\$?)(\\(\w[\w].*))(.doc|.rtf|.txt)$"


ControlToValidate="Message"></asp:RegularExpressionValidator>


Try with this, See u want to block yahoo, gmail etc etc. In the other
way round, specify only those domains u need, for eg: abc.com.It will
automatically block other domains not specified.
In the sample above replace .doc, .rtf,.txt with domains u need.

U can also give alert by using javascript.

Best Wishes
Raghav Mahajan







Sjaakie wrote:
> Not sure if I this belongs in this group or a Regex-group, but since it
> involves a WebControl I'll give it a try here.
>
> I want to block hotmail, yahoo and gmail addresses when typed into a
> TextBox control. Figured this could be done using a
> RegularExpressionValidator control, but I can't compose a valid
> expression to achieve this. Maybe you can help me out?
>
> I used the standard e-mail validation expression, and tried to alter it
> to filter Hotmail addresses. The expression below is incorrect...
>
> \w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*
>
> TIA


 
Reply With Quote
 
 
 
 
Sjaakie
Guest
Posts: n/a
 
      09-12-2006
Raghav,

Thanks for your reply, but I'm looking for an expression that fails if a
certain domain name is matched. If I use your approach I'll have to add
almost every domainname on the net just to block hotmail.com, yahoo.com
and gmail.com.


raghav schreef:
> Hiii
>
> <asp:RegularExpressionValidator
> id="xyz" runat="server"
> ErrorMessage="Message."
>
> ValidationExpression="^(([a-zA-Z]|(\\{2}\w+)\$?)(\\(\w[\w].*))(.doc|.rtf|.txt)$"
>
>
> ControlToValidate="Message"></asp:RegularExpressionValidator>
>
>
> Try with this, See u want to block yahoo, gmail etc etc. In the other
> way round, specify only those domains u need, for eg: abc.com.It will
> automatically block other domains not specified.
> In the sample above replace .doc, .rtf,.txt with domains u need.
>
> U can also give alert by using javascript.
>
> Best Wishes
> Raghav Mahajan
>
>
>
>
>
>
>
> Sjaakie wrote:
>> Not sure if I this belongs in this group or a Regex-group, but since it
>> involves a WebControl I'll give it a try here.
>>
>> I want to block hotmail, yahoo and gmail addresses when typed into a
>> TextBox control. Figured this could be done using a
>> RegularExpressionValidator control, but I can't compose a valid
>> expression to achieve this. Maybe you can help me out?
>>
>> I used the standard e-mail validation expression, and tried to alter it
>> to filter Hotmail addresses. The expression below is incorrect...
>>
>> \w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*
>>
>> TIA

>

 
Reply With Quote
 
raghav
Guest
Posts: n/a
 
      09-12-2006
Hiii
Fine i agree with u. My method will not be efficient if its many
domains.U can give alert by using java script. that is, if its equal to
yahoo.com or gmail.com, generate alert..

or try this:

ControlToValidate="to"
ValidationExpression=".*@yahoo.com*\..*"
ErrorInfo="<small>Invalid email address.</small>"
Display="Dynamic">
</asp:RegularExpressionValidator>

Hope this works, I am still doing R&D in google, if i find something
much better, i will post. U first try this for yahoo.com. If it works
for yahoo, we will add other domains like gmail etc etc...

Cheers
Raghav


Sjaakie wrote:
> Raghav,
>
> Thanks for your reply, but I'm looking for an expression that fails if a
> certain domain name is matched. If I use your approach I'll have to add
> almost every domainname on the net just to block hotmail.com, yahoo.com
> and gmail.com.
>
>
> raghav schreef:
> > Hiii
> >
> > <asp:RegularExpressionValidator
> > id="xyz" runat="server"
> > ErrorMessage="Message."
> >
> > ValidationExpression="^(([a-zA-Z]|(\\{2}\w+)\$?)(\\(\w[\w].*))(.doc|.rtf|.txt)$"
> >
> >
> > ControlToValidate="Message"></asp:RegularExpressionValidator>
> >
> >
> > Try with this, See u want to block yahoo, gmail etc etc. In the other
> > way round, specify only those domains u need, for eg: abc.com.It will
> > automatically block other domains not specified.
> > In the sample above replace .doc, .rtf,.txt with domains u need.
> >
> > U can also give alert by using javascript.
> >
> > Best Wishes
> > Raghav Mahajan
> >
> >
> >
> >
> >
> >
> >
> > Sjaakie wrote:
> >> Not sure if I this belongs in this group or a Regex-group, but since it
> >> involves a WebControl I'll give it a try here.
> >>
> >> I want to block hotmail, yahoo and gmail addresses when typed into a
> >> TextBox control. Figured this could be done using a
> >> RegularExpressionValidator control, but I can't compose a valid
> >> expression to achieve this. Maybe you can help me out?
> >>
> >> I used the standard e-mail validation expression, and tried to alter it
> >> to filter Hotmail addresses. The expression below is incorrect...
> >>
> >> \w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*
> >>
> >> TIA

> >


 
Reply With Quote
 
raghav
Guest
Posts: n/a
 
      09-12-2006
ValidationExpression=".6a.6\..6"

after posting it did display properly, so writing again

in above string replace
6 with------------->*(asteric)
a with-------------->@(at)
just after a write yahoo.com and becareful with .(dot) marks, no space
try it
Raghav..




raghav wrote:
> Hiii
> Fine i agree with u. My method will not be efficient if its many
> domains.U can give alert by using java script. that is, if its equal to
> yahoo.com or gmail.com, generate alert..
>
> or try this:
>
> ControlToValidate="to"
> ValidationExpression=".*@yahoo.com*\..*"
> ErrorInfo="<small>Invalid email address.</small>"
> Display="Dynamic">
> </asp:RegularExpressionValidator>
>
> Hope this works, I am still doing R&D in google, if i find something
> much better, i will post. U first try this for yahoo.com. If it works
> for yahoo, we will add other domains like gmail etc etc...
>
> Cheers
> Raghav
>
>
> Sjaakie wrote:
> > Raghav,
> >
> > Thanks for your reply, but I'm looking for an expression that fails if a
> > certain domain name is matched. If I use your approach I'll have to add
> > almost every domainname on the net just to block hotmail.com, yahoo.com
> > and gmail.com.
> >
> >
> > raghav schreef:
> > > Hiii
> > >
> > > <asp:RegularExpressionValidator
> > > id="xyz" runat="server"
> > > ErrorMessage="Message."
> > >
> > > ValidationExpression="^(([a-zA-Z]|(\\{2}\w+)\$?)(\\(\w[\w].*))(.doc|.rtf|.txt)$"
> > >
> > >
> > > ControlToValidate="Message"></asp:RegularExpressionValidator>
> > >
> > >
> > > Try with this, See u want to block yahoo, gmail etc etc. In the other
> > > way round, specify only those domains u need, for eg: abc.com.It will
> > > automatically block other domains not specified.
> > > In the sample above replace .doc, .rtf,.txt with domains u need.
> > >
> > > U can also give alert by using javascript.
> > >
> > > Best Wishes
> > > Raghav Mahajan
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Sjaakie wrote:
> > >> Not sure if I this belongs in this group or a Regex-group, but since it
> > >> involves a WebControl I'll give it a try here.
> > >>
> > >> I want to block hotmail, yahoo and gmail addresses when typed into a
> > >> TextBox control. Figured this could be done using a
> > >> RegularExpressionValidator control, but I can't compose a valid
> > >> expression to achieve this. Maybe you can help me out?
> > >>
> > >> I used the standard e-mail validation expression, and tried to alter it
> > >> to filter Hotmail addresses. The expression below is incorrect...
> > >>
> > >> \w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*
> > >>
> > >> TIA
> > >


 
Reply With Quote
 
Sjaakie
Guest
Posts: n/a
 
      09-13-2006
raghav wrote:
> Hiii
> Fine i agree with u. My method will not be efficient if its many
> domains.U can give alert by using java script. that is, if its equal to
> yahoo.com or gmail.com, generate alert..
>
> or try this:
>
> ControlToValidate="to"
> ValidationExpression=".*@yahoo.com*\..*"
> ErrorInfo="<small>Invalid email address.</small>"
> Display="Dynamic">
> </asp:RegularExpressionValidator>
>
> Hope this works, I am still doing R&D in google, if i find something
> much better, i will post. U first try this for yahoo.com. If it works
> for yahoo, we will add other domains like gmail etc etc...
>
> Cheers
> Raghav
>
>
> Sjaakie wrote:
>> Raghav,
>>
>> Thanks for your reply, but I'm looking for an expression that fails if a
>> certain domain name is matched. If I use your approach I'll have to add
>> almost every domainname on the net just to block hotmail.com, yahoo.com
>> and gmail.com.
>>
>>
>> raghav schreef:
>>> Hiii


>>> Try with this, See u want to block yahoo, gmail etc etc. In the other
>>> way round, specify only those domains u need, for eg: abc.com.It will
>>> automatically block other domains not specified.
>>> In the sample above replace .doc, .rtf,.txt with domains u need.
>>>
>>> U can also give alert by using javascript.
>>>
>>> Best Wishes
>>> Raghav Mahajan


>>> Sjaakie wrote:
>>>> Not sure if I this belongs in this group or a Regex-group, but since it
>>>> involves a WebControl I'll give it a try here.
>>>>
>>>> I want to block hotmail, yahoo and gmail addresses when typed into a
>>>> TextBox control. Figured this could be done using a
>>>> RegularExpressionValidator control, but I can't compose a valid
>>>> expression to achieve this. Maybe you can help me out?
>>>>
>>>> I used the standard e-mail validation expression, and tried to alter it
>>>> to filter Hotmail addresses. The expression below is incorrect...
>>>>
>>>> \w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*
>>>>
>>>> TIA

>


Raghav,
I finally managed to write an expression that detects hotmail, yahoo and
gmail addresses:

..*@(?!hotmail)(?!gmail)(?!yahoo).*

Thanks for your help!
 
Reply With Quote
 
raghav
Guest
Posts: n/a
 
      09-13-2006
Hii
Thats really nice!!! i will also copy this string for future
reference

Best Wishes
Raghav



Sjaakie wrote:

> raghav wrote:
> > Hiii
> > Fine i agree with u. My method will not be efficient if its many
> > domains.U can give alert by using java script. that is, if its equal to
> > yahoo.com or gmail.com, generate alert..
> >
> > or try this:
> >
> > ControlToValidate="to"
> > ValidationExpression=".*@yahoo.com*\..*"
> > ErrorInfo="<small>Invalid email address.</small>"
> > Display="Dynamic">
> > </asp:RegularExpressionValidator>
> >
> > Hope this works, I am still doing R&D in google, if i find something
> > much better, i will post. U first try this for yahoo.com. If it works
> > for yahoo, we will add other domains like gmail etc etc...
> >
> > Cheers
> > Raghav
> >
> >
> > Sjaakie wrote:
> >> Raghav,
> >>
> >> Thanks for your reply, but I'm looking for an expression that fails if a
> >> certain domain name is matched. If I use your approach I'll have to add
> >> almost every domainname on the net just to block hotmail.com, yahoo.com
> >> and gmail.com.
> >>
> >>
> >> raghav schreef:
> >>> Hiii

>
> >>> Try with this, See u want to block yahoo, gmail etc etc. In the other
> >>> way round, specify only those domains u need, for eg: abc.com.It will
> >>> automatically block other domains not specified.
> >>> In the sample above replace .doc, .rtf,.txt with domains u need.
> >>>
> >>> U can also give alert by using javascript.
> >>>
> >>> Best Wishes
> >>> Raghav Mahajan

>
> >>> Sjaakie wrote:
> >>>> Not sure if I this belongs in this group or a Regex-group, but since it
> >>>> involves a WebControl I'll give it a try here.
> >>>>
> >>>> I want to block hotmail, yahoo and gmail addresses when typed into a
> >>>> TextBox control. Figured this could be done using a
> >>>> RegularExpressionValidator control, but I can't compose a valid
> >>>> expression to achieve this. Maybe you can help me out?
> >>>>
> >>>> I used the standard e-mail validation expression, and tried to alter it
> >>>> to filter Hotmail addresses. The expression below is incorrect...
> >>>>
> >>>> \w+(-+.]\w+)*@(\w+!hotmail)([-/]\w+)*\.\w+(-.]\w+)*
> >>>>
> >>>> TIA

> >

>
> Raghav,
> I finally managed to write an expression that detects hotmail, yahoo and
> gmail addresses:
>
> .*@(?!hotmail)(?!gmail)(?!yahoo).*
>
> Thanks for your help!


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set the RegularExpression ad ASP .Net 2 06-13-2005 10:47 PM
RegularExpression validator that does not allow blanks John Hoge ASP .Net 2 05-23-2004 05:26 PM
RegularExpression code for server-side validation of Date =?Utf-8?B?bWc=?= ASP .Net 3 05-19-2004 11:03 PM
Regularexpression validator on multiline text box Stephan Bour ASP .Net 2 10-28-2003 09:42 PM
Email RegularExpression not working Learning SQL Server ASP .Net 4 08-08-2003 08:51 AM



Advertisments