Print everyhing before and after at

Posted on 2011-09-15
Last Modified: 2012-05-12
If i get an email adress from a database like this <%= rs("email") %> and it contains the adress How do i do if i want to break up this in two variables one that is called user which contains mc and one called domain that includes pz-net.

With other words i want one variable with everything before at (@) and one from everyhing after.
Question by:MickeC
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 31

Expert Comment

by:Wayne Barron
ID: 36541992
Here is what I use, and it works pretty well.

getName = Left(email,InStr(email,"@")-1)
chDomain = Mid(email,instr(email,"@")+1)

Open in new window

Good Luck

Expert Comment

ID: 36541993
Use the split() function

var sMail = rs("email")
var aMail = split(sMail, "@")
var sUser = aMail[0]
var sDomain = aMail[1]
LVL 31

Accepted Solution

Wayne Barron earned 500 total points
ID: 36542001
Forgot something
For your code, you will need it to be like so.

email = rs("email")
getName = Left(email,InStr(email,"@")-1)
chDomain = Mid(email,instr(email,"@")+1)

Open in new window

LVL 31

Expert Comment

by:Wayne Barron
ID: 36548052
Glad I could help.
This code is a life saver, big time.

Take Care

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question