Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display asterisk in email address before @ symbol

Status
Not open for further replies.

charanch

Programmer
Jan 3, 2004
55
US
Hello, I am setting up a page where customers can look up their customer number by entering their first and last names, but since some have the same first name and last name (i.e. kim brown), I would like to partially display their email address but put * before the @ sign so their entire email address does not display (i.e. *@aol.com). Can this be done, and if so, where do I start? Thank you VERY much.

cr
 
I'm making the following assumptions:
[ul][li]Email addresses are stored in a database[/li][li]The database fieldtype is VARCHAR[/li][/ul]

If so, then:
[tt]
SELECT REPLACE([fieldname], LEFT([fieldname],(PATINDEX('%@%', [fieldname])-1)), '***') FROM [tablename][/tt]

This query will change everything before the @ sign to three asterisks (***@whaterver.com).

If you want to replace the @whatever.com (e.g., yourname@***) then the following query will do the trick:

[tt]SELECT REPLACE([fieldname], RIGHT([fieldname],(LEN([fieldname])- PATINDEX('%@%', [fieldname]))), '***') FROM [tablename][/tt]

Hope this helps.


Krickles | 1.6180

 
Nevermind. I used the code from another thread to get rid of everything before the @ symbol. I posted it below. However, if there is a better way, let me know. Thanks.

Code:
myString=rsCheck("email")
if myString>"" then
myPos = InStrRev(myString,"@")
myNewString = mid(myString,myPos+1)
else
myNewString="No email Address"
end if
 
I prefer to do as much work server side as possible. The only advantage to my script is it puts the work on the server.

Krickles | 1.6180

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top