none
Regular expression for CLR(C#) in SSIS RRS feed

  • Question

  • Hi

    I have below Oracle regular expression that validates email-id. I need to convert this into its equivalent regex 
    that I can use in CLR program in SSIS.

    /^(\s*[a-zA-Z0-9_\'-.])@([a-zA-Z0-9_-.]).([a-zA-Z]{2,5})$/

    Can someone pls help me convert?

    In plain english below is the rule:

    1.An email should start with any non-white space character

    2. Preceding with zero or more characters from the list of: a-z A-Z 0-9 - _ ' .

    3. @(at symbol)

    4. Any character from the list of: a-z A-Z 0-9 - _ .

    5. .(dot symbol)

    6. Any character from the list of: a-z A-Z between the size of 2 to 5 characters.

    Tuesday, March 27, 2018 6:11 AM

All replies

  • Seems that you expression does not satisfy some of the rules. Therefore, it is early to convert it.

    But in C# you can validate an E-mail using MailAddress class:

     

    It will cover more valid variants.

    • Edited by Viorel_MVP Tuesday, March 27, 2018 9:08 AM
    Tuesday, March 27, 2018 9:03 AM
  • Your Oracle expression is wrong. Email formats allow a lot more variety then that. I wouldn't use it. As an example you are allowed to have any # of subdomains. So requiring abc.def is going to limit a lot of email addresses.

    As Viorel mentions, use MailAddress as it already validates emails that follow almost all the rules of the RFC.


    Michael Taylor http://www.michaeltaylorp3.net

    Wednesday, March 28, 2018 2:50 PM
    Moderator