Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hide Email Address From View

New Here ,
May 01, 2009 May 01, 2009

We have clients that we have told not to post their email in a textarea form and they do it anyway.  Is there a way to find the email address in the textarea output (public view page) and then ******* or whatever their entire email address before and after the @??  We do not want any of the email showing.  Thanks in advance.

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , May 01, 2009 May 01, 2009

You could use a regular expression (where appropriate in the flow of your code) to locate an email address and replace it with the desired characters. Here's a sample:

ReReplaceNoCase( originalString, "^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$", "*********@******", "ALL" )

This snippet should find any email addresses in the variable originalString and replace it with *********@******.

Hope that helps!

Translate
Advocate ,
May 01, 2009 May 01, 2009

You could use a regular expression (where appropriate in the flow of your code) to locate an email address and replace it with the desired characters. Here's a sample:

ReReplaceNoCase( originalString, "^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$", "*********@******", "ALL" )

This snippet should find any email addresses in the variable originalString and replace it with *********@******.

Hope that helps!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 01, 2009 May 01, 2009

Thanks!  You rock!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 01, 2009 May 01, 2009

Hmmm....the code is still not finding the emails in the output.  Any ideas on why this would not work?  The output is just a paragraph of data submitted through a textarea form.

#ReReplaceNoCase(data.comments,"^[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}$", "*********@******", "ALL")#

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 01, 2009 May 01, 2009

Could you post or send me a sample of the data.comments text? (Is this from a DB where data is the query and comments the field?). I'd probably have better luck looking at a bit of the code!

Cheers,

Craig

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 01, 2009 May 01, 2009

Yes, it is a straight output of an NText SQL database field from a query = #data.comments# - no other code.    The output may contact several paragraphs.  I am just trying to find and mask email addresses placed there so no direct contact can be made.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 01, 2009 May 01, 2009

Thanks. Running a few tests now...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 01, 2009 May 01, 2009

Okay, this was my bad. I sent you a regexp that I use to validate emails from a form, where the email would be the only text in the string. The regexp had two characters (the first, or ^, and the last, $) that need to be removed. The ^ character looks for a regexp at the start of a string and the $ indicates the end of a string. Removing these characters from the regexp makes it work.

Here's a sample of working code (just tested):

<cfsavecontent variable="comments">

This is my content. It has some text in it. It also has some email addresses in it. One address is myemail@domain.com and another email is from myotheremail@domain.co.uk. Yet another email address would be from a friend and it is athirdemail@gmail.com.

</cfsavecontent>

<cfscript>

cleanContent = ReReplaceNoCase( comments, "[a-zA-Z_0-9-'\+~]+(\.[a-zA-Z_0-9-'\+~]+)*@([a-zA-Z_0-9-]+\.)+[a-zA-Z]{2,7}", "*********@******", "ALL" )

</cfscript>

<cfoutput>ORIGINAL TEXT: <br />#comments#</cfoutput>

<cfoutput>CLEANED TEXT: <br />#cleanContent#</cfoutput>

Sorry about that, I did not look closely enough at my regexp. This one does work though!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 01, 2009 May 01, 2009

Thanks for your help!  Works great now.  Have a great weekend!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 01, 2009 May 01, 2009
LATEST

You are welcome. Sorry for the goof on the initial regexp and you have a great weekend, too!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources