STRIP

The function STRIP removes all designated characters from a given string.

This function takes two strings as input: one is the base string, from which characters will be striped, and the other designates which characters will be removed. It outputs the base string sans any of the characters that were designated to be removed.

Declaration

STRIP(base_string, characters) -> string

 

Parameters

base_string (required, type: string)
The base string, from which characters will be striped.

characters (required, type: string)
A string containing the characters that will be stripped from the base string.

Return Values

string (type: string)
The string that results from stripping the base string of all the characters designated to be striped.

Examples

The following example strips all instances of the character "i" from the string "This is a string". Note that there are no "i"s at all in the end result:

STRIP("This is a string", "i") -> "Ths s a strng"

The following example strips all instances of the characters "i" and "s" from the string "This is a string". Note that it is not just instances of the string "is" – "i" and "s" together – that are removed from the base string; there are absolutely no "i"s and no "s"s in the end result:

STRIP("This is a string", "is") -> "Th  a trng"

The order in which characters are listed does not matter. The following example yields the same output as the above example, even though the characters "i" and "s" are given in reverse order:

STRIP("This is a string", "si") -> "Th  a trng"

If the same character is given multiple times in the characters string, the STRIP function behaves as though it was given only once. The following example lists the character "i" six separate times in the characters string, and the output is identical to the the output in the first example, where "i" was listed in the characters string only once:

STRIP("This is a string", "iiiiii") -> "Ths s a strng"

A space is a perfectly valid character to strip from a string. The following example strips all instances of the characters "i", " ", and "s" from the string "This is a string":

STRIP("This is a string", "i s") -> "Thatrng"

The STRIP function requires a characters string as input in order to run, but it can technically accept a blank string as characters. Should this be the case, STRIP will return the base function unmodified. The following example takes the string "This is a string", strips nothing from it, and returns it in its entirety:

STRIP("This is a string", "") -> "This is a string"

The STRIP function is case sensitive. The following example takes the string "This is a string" and strips away any instances of "I". None of the "i"s in "This is a string" are capitalized, and so the STRIP function returns the base string unmodified:

STRIP("This is a string", "I") -> "This is a string"