RegularExpression for filtering unwanted e-mail address

Discussion in 'ASP .Net' started by Sjaakie, Sep 12, 2006.

  1. Sjaakie

    Sjaakie Guest

    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
    Sjaakie, Sep 12, 2006
    #1
    1. Advertising

  2. Sjaakie

    raghav Guest

    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
    raghav, Sep 12, 2006
    #2
    1. Advertising

  3. Sjaakie

    Sjaakie Guest

    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

    >
    Sjaakie, Sep 12, 2006
    #3
  4. Sjaakie

    raghav Guest

    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

    > >
    raghav, Sep 12, 2006
    #4
  5. Sjaakie

    raghav Guest

    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
    > > >
    raghav, Sep 12, 2006
    #5
  6. Sjaakie

    Sjaakie Guest

    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!
    Sjaakie, Sep 13, 2006
    #6
  7. Sjaakie

    raghav Guest

    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!
    raghav, Sep 13, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Learning SQL Server

    Email RegularExpression not working

    Learning SQL Server, Aug 7, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    2,457
    Chris R. Timmons
    Aug 8, 2003
  2. Stephan Bour
    Replies:
    2
    Views:
    7,169
    Stephan Bour
    Oct 28, 2003
  3. =?Utf-8?B?bWc=?=
    Replies:
    3
    Views:
    931
    Peter Blum
    May 20, 2004
  4. newbie
    Replies:
    2
    Views:
    236
    newbie
    Mar 3, 2004
  5. Bob Emmett

    Tons of unwanted mail in my E-Mail

    Bob Emmett, Apr 5, 2009, in forum: Ruby
    Replies:
    2
    Views:
    102
    forgottenwizard
    Apr 6, 2009
Loading...

Share This Page