Skip to main content
July 28, 2011
Question

Seacrh For double Quotes with ListFindNoCase

  • July 28, 2011
  • 3 replies
  • 978 views

My user entered  street names with double quotes and crashed my app.:

"32 street" instead of just 32 street.

I did not think of checking for double quotes at the time and I need to modify my codes now.

I need to find how many address entry has double quotes then produce a report so users can fix their feed.

I think my syntax below i wrong that's why I got error mesage from CF. Can anyone help with the right syntax on how to search a double quores in a string?

<CFIF ListFindNoCase(StreetName, " " ") NEQ 0>

  create report

</CFIF>

This topic has been closed for replies.

3 replies

Inspiring
August 13, 2011

My user entered  street names with double quotes and crashed my app.:

"32 street" instead of just 32 street.

I did not think of checking for double quotes at the time and I need to modify my codes now.

I need to find how many address entry has double quotes then produce a report so users can fix their feed.

Instead of "fixing" the data, why don't you fix your app so that the double quotes aren't a problem?  Don't treat the symptom: treat the problem.

--

Adam

BKBK
Community Expert
Community Expert
August 13, 2011

Adam Cameron. wrote:

My user entered  street names with double quotes and crashed my app.:

"32 street" instead of just 32 street.

I did not think of checking for double quotes at the time and I need to modify my codes now.

I need to find how many address entry has double quotes then produce a report so users can fix their feed.

Instead of "fixing" the data, why don't you fix your app so that the double quotes aren't a problem?  Don't treat the symptom: treat the problem.

--

Adam

I agree. Granted, it is often difficult, even impossible, to fix your application such that users will enter the kind of data you want. However, your application shouldn't crash because of bad user input. This suggests you should validate the form variables. 

BKBK
Community Expert
Community Expert
August 13, 2011

GKiew wrote:

<CFIF ListFindNoCase(StreetName, " " ") NEQ 0>

  create report

</CFIF>

Almost.

<cfif findNoCase('"', streetname) NEQ 0> <!--- single quote, double quote, single quote, in that order, without spaces in between --->

Inspiring
July 28, 2011

First, you want to use contains, not ListFindNoCase.

Next, if the string you seek contains double quotes, use single quotes to quote the string, and vice versa.

Or, you can look for chr(34).