WeCodeThings Library
Library of code bits
Glossary    Contact Us
Need a web designer? visit WeCodeThings.Com for more details
Search  
   
Browse by Category


WeCodeThings Library .: ColdFusion .: Helpful Functions .: ColdFusion Remove Quotes Single Double or Both from a String



ColdFusion Remove Quotes Single Double or Both from a String

This helpful little ColdFusion function, removes all quotes from a string that is passed into it. It will remove single, double or both single and double quotes from a string that is passed into it.

  1. <cffunction name="stripQuotes" access="public" output="false" returntype="string"
  2.                         hint="Strips quotes from a string.">
  3.         <cfargument name="stripMe" type="string" required="true" hint="String from which to strip quotes."/>
  4.         <cfargument name="type" type="string" required="false" default="BOTH" hint="A list of the quote types to strip. Allowed values: SINGLE,DOUBLE, or BOTH. Ignores other values. Defaults to BOTH."/>
  5.         <cfset var stripChars = ""/>
  6.         <cfset var returnVal  = arguments.stripMe/>
  7.  
  8.         <cfswitch expression="#trim(arguments.type)#">
  9.                 <cfcase value="SINGLE">
  10.                         <cfset stripChars = "'"/>
  11.                 </cfcase>
  12.                 <cfcase value="DOUBLE">
  13.                         <cfset stripChars = '"'/>
  14.                 </cfcase>
  15.                 <cfdefaultcase>
  16.                         <cfset stripChars = '''"'/>
  17.                 </cfdefaultcase>
  18.         </cfswitch>
  19.  
  20.         <cfset returnVal = reReplace(arguments.stripMe, "[" & stripChars & "]", "", "ALL")/>
  21.  
  22.         <cfreturn returnVal/>
  23. </cffunction>


How helpful was this article to you?

Related Articles

article ColdFusion Find Out How Long Ago a Date or String was from now
This ColdFusion function accepts a string...

(No rating)  12-3-2009    Views: 399   
article How to display Random Quote using ColdFusion and the RandRange Function
<!--- Be sure to change...

(No rating)  4-7-2009    Views: 807   
article Flex 3 Add Custom Error using the errorString to a TextBox or Any Object using Object.errorString Flex 3
You can add a custom error to any element o

  4-30-2009    Views: 1243   

User Comments

Add Comment
No comments have been posted.




.: Powered by Lore .:Code by WeCodeThings Website Design and Development