Get User Name from Email String

Discussion in 'ASP General' started by Scott, Feb 5, 2006.

  1. Scott

    Scott Guest

    I need to get the userName from an Email address. For example, if the email
    is , how can I can I get just the "username" part using the
    RIGHT() or LEFT() functions?
     
    Scott, Feb 5, 2006
    #1
    1. Advertising

  2. Scott

    McKirahan Guest

    "Scott" <> wrote in message
    news:...
    > I need to get the userName from an Email address. For example, if the

    email
    > is , how can I can I get just the "username" part using

    the
    > RIGHT() or LEFT() functions?



    Const c = ""

    Dim a
    a = Split(c,"@")
    Response.Write a(0)

    or

    Dim s
    s = Left(c,InStr(c,"@")-1)
    Response.Write s
     
    McKirahan, Feb 5, 2006
    #2
    1. Advertising

  3. Scott

    Evertjan. Guest

    McKirahan wrote on 05 feb 2006 in
    > "Scott" <> wrote in message
    >> I need to get the userName from an Email address. For example, if the
    >> email is , how can I can I get just the "username"
    >> part using the
    >> RIGHT() or LEFT() functions?

    >
    > Const c = ""
    >
    > Dim a
    > a = Split(c,"@")
    > Response.Write a(0)


    or in ASP-jscript

    var c = "";
    response.write( c.split('@')[0] );


    > or
    >
    > Dim s
    > s = Left(c,InStr(c,"@")-1)
    > Response.Write s


    or use a ASP-vbs regex:

    c = ""
    Set regEx = New RegExp
    regEx.Pattern = "@.*"
    Response.Write regEx.Replace(c, "")

    or a ASP-jscript regex:

    var c = "";
    response.write( c.replace(/@.*/, '') );

    There are many ways to reach Rome:
    you can take a scenic route or a fast one,
    relying on classic Basic Left() and Right() could be
    the OP's preference though.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 5, 2006
    #3
    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. nalbayo
    Replies:
    2
    Views:
    5,599
    Bruce Barker
    Nov 11, 2005
  2. Jared
    Replies:
    5
    Views:
    5,832
    Bill Yellin
    Jan 4, 2006
  3. ding feng
    Replies:
    2
    Views:
    2,913
    ding feng
    Jun 25, 2003
  4. Antonio O''Neal

    user.identity.name returns old AD user name

    Antonio O''Neal, Oct 31, 2008, in forum: ASP .Net Security
    Replies:
    5
    Views:
    2,302
    Antonio O''Neal
    Nov 3, 2008
  5. Replies:
    5
    Views:
    132
Loading...

Share This Page