freelanceprogrammers.org Forum Index » Cold Fusion

Replacing Special Characters


View user's profile Post To page top
Chrystalheart Posted: Thu Jul 07, 2005 12:32 am


Joined: 05 Apr 2005

Posts: 37
Replacing Special Characters
I am replacing special characters in a string with a hyphen. It works
great except I am stuck on how to get it to work when replacing a #
and when replacing a comma.

<cfif #listContains(ffields,"#")# is not 0><cfset ffields=#Replace
(ffields,"#","-","ALL")#></cfif>

<cfif #listContains(ffields,",")# is not 0><cfset ffields=#Replace
(ffields,",","-","ALL")#></cfif>

Any ideas?

Jen
Reply with quote
Send private message
View user's profile Post To page top
scotthughey Posted: Sat Jul 09, 2005 4:57 am


Joined: 09 Jul 2005

Posts: 1
Replacing Special Characters
If I`m not mistaken, the code should read like this:

<cfif #listContains(ffields,"##")# is not 0>
<cfset ffields=#Replace
(ffields,"##","-","ALL")#>
</cfif>

<cfif #listContains(ffields,",")# is not 0>
<cfset ffields=#Replace
(ffields,",","-","ALL")#>
</cfif>

For CF to know that # is an actual number sign, you have to
type it twice. You might also consider using <cfelse> so
that it doesn`t have to process each if statement.
Depending on how the code is written, that might improve
performance.

-Scott Hughey
<<
I am replacing special characters in a string with a
hyphen. It works
great except I am stuck on how to get it to work when
replacing a #
and when replacing a comma.

<cfif #listContains(ffields,"#")# is not 0><cfset
ffields=#Replace
(ffields,"#","-","ALL")#></cfif>

<cfif #listContains(ffields,",")# is not 0><cfset
ffields=#Replace
(ffields,",","-","ALL")#></cfif>

Any ideas?

Jen>>



__________________________________
Yahoo! Mail for Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help