Compartir a través de


STUFF( ) Function

Returns a character string created by replacing a specified number of characters in a character expression with another character expression.

STUFF(cExpression, nStartReplacement, nCharactersReplaced, cReplacement)

Parameters

  • cExpression
    Specify the character expression in which the replacement occurs.

  • nStartReplacement
    Specifies the position in cExpression where the replacement begins.

  • nCharactersReplaced
    Specifies the number of characters to be replaced. If nCharactersReplaced is 0, the replacement string cReplacement is inserted into cExpression.

  • cReplacement
    Specifies the replacement character expression. If cReplacement is the empty string, the number of characters specified by nCharactersReplaced are removed from cExpression.

Return Value

Character

Example

STORE 'abcdefghijklm' TO gcString1
STORE '12345' TO gcString2
CLEAR
? STUFF(gcString1, 4, 0, gcString2)     && insert
? STUFF(gcString1, 4, 3, gcString2)     && replace
? STUFF(gcString1, 4, 6, '')     && delete
? STUFF(gcString1, 4, 1, gcString2)     && replace and insert
? STUFF(gcString1, 4, 4, gcString2)     && replace and delete
? STUFF(gcString1, 4, LEN(gcString1), gcString2)   && replace, delete rest

See Also

Reference

LEFT( ) Function

PADL( ) | PADR( ) | PADC( ) Functions

RIGHT( ) Function

STRTRAN( ) Function

SUBSTR( ) Function

Other Resources

Functions

Language Reference (Visual FoxPro)