Solved

Print everyhing before and after at

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

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…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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