Hi Lee,

You are on the right track with ReReplace

Try:

<cfset str = "This is a string with £ and ? characters" >

<cfset str_safe = ReReplaceNoCase(str,"[ [EMAIL PROTECTED]&*+=-]","_","ALL") >

<cfset str_safe = ReReplaceNoCase(str_safe,"__","_","ALL") >
<cfset str_safe = ReReplaceNoCase(str_safe,"__","_","ALL") >
<cfset str_safe = ReReplaceNoCase(str_safe,"__","_","ALL") >

The last 3 functions simply changes long series of ________ into _ for neatness.

Cheers,
Martyn


  ----- Original Message ----- 
  From: Lee Bailey 
  To: CF-Talk 
  Sent: Friday, August 11, 2006 8:26 PM
  Subject: Stripping Characters from a String


  Hi Folks,

  I'm trying to strip characters from a form string, like so;

  The entered text : This is a string with £ and ? characters
  The desired result : this_is_a_string_with_and_characters

  The aim is that I can use this as a 'safe' URL parameter for navigating the 
website. Obviously, if the string contains things like ? then it throws an 
error, or simply doesn't return the record.

  As I also need to use the original entered text (the entered text will be 
known as 'heading', and the modified text will be known as 'shortheading' 
within the DB) I can only accomplish this on the action page, not through 
javascript.

  I can't use URLEncodedFormat() because the string needs to be easily readable 
in the address bar (and look good to google!).

  Looking at my CFWACK book, ReReplace() seems to be the tag I need, but 
despite numerous efforts I just can't get a working syntax.

  Any help would be much appreciated!

  

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:249534
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to