[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Print everyhing before and after at

Posted on 2011-09-15
4
Medium Priority
?
294 Views
Last Modified: 2012-05-12
Hi!
If i get an email adress from a database like this <%= rs("email") %> and it contains the adress mc@pz-net.com. 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.
0
Comment
Question by:MickeC
  • 3
4 Comments
 
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
Carrzkiss
0
 
LVL 7

Expert Comment

by:Ironhoofs
ID: 36541993
Use the split() function

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

Accepted Solution

by:
Wayne Barron earned 2000 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


Carrzkiss
0
 
LVL 31

Expert Comment

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

Take Care
Carrzkiss
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

829 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