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

Stripping Characters from a String

Guest
Aug 10, 2006 Aug 10, 2006

Copy link to clipboard

Copied

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.

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!
TOPICS
Advanced techniques

Views

385

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
Contributor ,
Aug 10, 2006 Aug 10, 2006

Copy link to clipboard

Copied

It seems like you're trying to reinvent something that already exists. Take a look at the function URLEncodedFormat(). It will convert a string of text into a URL-safe form. Your string,for example, would become:

This%20is%20a%20string%20with%20%C2%A3%20and%20%3F%20characters

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
Guest
Aug 10, 2006 Aug 10, 2006

Copy link to clipboard

Copied

Thanks for the reply. I was aware of that function, but for the purpose of my needs, it is too messy. Part of the reason for wanting the solution done in the way mentioned above is so it 'looks' identifyable in the browser. Obviously there are SEO benefits too.

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
Guest
Aug 15, 2006 Aug 15, 2006

Copy link to clipboard

Copied

Maybe you can have two URL params?

One that looks messy but will always work
and one that looks identifiable in the browser?

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
Participant ,
Aug 16, 2006 Aug 16, 2006

Copy link to clipboard

Copied

LATEST
Perhaps this may help you in your endeavor.

Adam

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