removeChars

Description

Removes characters from a string.

Categories

Related

Syntax

RemoveChars(string, start, count)

Attributes

AttributeDescriptionRequiredDefault
countNumber of characters to remove.
startA positive integer or a variable that contains one. Position at which to start search.
stringA string or a variable that contains one. String in which to search.

Returns

A copy of the string, with count characters removed from the specified start position. If no characters are found, returns zero.

Example

<h3>RemoveChars Example</h3> 
Returns a string with <I>count</I> characters removed from the  
    start position. Returns 0 if no characters are found. 
 
<cfif IsDefined("FORM.myString")> 
    <cfif (FORM.numChars + FORM.start) GT Len(FORM.myString)> 
        Your string is only <cfoutput>#Len(FORM.myString)# 
         </cfoutput> characters long. 
        Please enter a longer string, select fewer characters to remove or 
        begin earlier in the string. 
    <cfelse> 
        <cfoutput> 
        Your original string:     #FORM.myString# 
        Your modified string:    #RemoveChars(FORM.myString, 
    FORM.start, FORM.numChars)#  
        </cfoutput> 
    </cfif> 
</cfif>