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

Having problems with a replace function

Participant ,
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

Can one of you guys please tell me what I am doing wrong here. I have 3 sets of characters that word produces which I must replace in my strings before they enter the DB. Here are the characters.

— Remove this dash with  - 

’ Remove this apostrophe with '

“ Remove this left double quote with "

” Remove this right double quote with "

My Problem is that the replace() function only gets the first occurance and replaces that. Not all occurances. How can I make it replace all occurances? Here is my code.

TOPICS
Advanced techniques

Views

332

Translate

Translate

Report

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

Participant , May 08, 2006 May 08, 2006
I figured it out. I was missing the ALL parameter.

<cfscript>
form.test = replace(#form.test#, "&mdash;", " - ", "ALL");
form.test = replace(#form.test#, "&rsquo;", "'", "ALL");
form.test = replace(#form.test#, "&ldquo;", """", "ALL");
form.test = replace(#form.test#, "&rdquo;", """", "ALL");
</cfscript>

Votes

Translate

Translate
Participant ,
May 08, 2006 May 08, 2006

Copy link to clipboard

Copied

LATEST
I figured it out. I was missing the ALL parameter.

<cfscript>
form.test = replace(#form.test#, "&mdash;", " - ", "ALL");
form.test = replace(#form.test#, "&rsquo;", "'", "ALL");
form.test = replace(#form.test#, "&ldquo;", """", "ALL");
form.test = replace(#form.test#, "&rdquo;", """", "ALL");
</cfscript>

Votes

Translate

Translate

Report

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
Documentation