Solved

Print everyhing before and after at

Posted on 2011-09-15
4
281 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 30

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 30

Accepted Solution

by:
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


Carrzkiss
0
 
LVL 30

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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/…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now