Removes types of characters and individual characters from a specified string.
Examples
The following example strips out all numeric characters. Because a numeric string is not converted to canonical form, the characters + and E are not stripped out:
SET str="+123E4"
WRITE $ZSTRIP(str,"*N")
returns: +E
In the following example, the first $ZSTRIP strips all punctuation characters, the second $ZSTRIP strips all punctuation characters except whitespace characters.
SET str="ABC#$%^ DEF& *GHI***"
WRITE $ZSTRIP(str,"*P"),!
WRITE $ZSTRIP(str,"*P'W")
The following example strips out all characters, except lowercase letters ('L). However, the example uses the remchar argument to strip the lowercase x while preserving all other lowercase characters:
SET str="xXx-Aa BXXbx Cxc Dd xxEeX^XXx"
WRITE $ZSTRIP(str,"*E'L","x")
returns: abcde
The following example strips out all characters, except lowercase letters ('L). In this case, the example does not specify a remchar argument value (but does specify the delimiting commas), but does specify the keepchar argument to preserve uppercase A, B, and C:
SET str="X-Aa BXXb456X CXc Dd XXEeX^XFFFfXX"
WRITE $ZSTRIP(str,"*E'L",,"ABC")
returns: AaBbCcdef
The following example does not specify a mask code; it specifies to remove the letters “X” and “x” wherever they occur in the string. All other characters in the string are returned.
SET str="+x $1x,x23XX4XX.X56XxxxxxX"
WRITE $ZSTRIP(str,"*","Xx")
returns: + $1,234.56
The following example does not specify a mask code; it specifies to remove the character “x” as a leading or trailing character, and to removed repeating “x”s wherever they occurs within the string:
SET str="xxxxx00xx0111xxx01x0000xxxxx"
WRITE $ZSTRIP(str,"<=>","x")
returns: 00x0111x01x0000
The following example strips out all numeric, alphabetic, and punctuation characters, except whitespace and lowercase letters. Note that all mask codes without a Unary Not must precede any mask codes with a Unary Not:
SET str="Aa66*&% B&$b Cc987 #Dd Ee"
WRITE $ZSTRIP(str,"*NAP'W'L")
returns: a b c d e
The following example strips out leading, trailing, and repeating characters that match the mask code A (all alphabetic characters):
SET str="ABC123DDDEEFFffffGG5555567HI JK"
WRITE $ZSTRIP(str,"<=>A")
It returns 123DEFfG5555567HI; $ZSTRIP stripped leading characters (ABC) until it encountered a character of a type not included in the mask (1), and stripped trailing characters from the end of the string until it encountered a non-mask character (the blank space). Repeated characters of the mask type were reduced to a single occurrence (DDDEE = DE); note that the repeat test is case-sensitive (FFffff = Ff). Repeated characters that are not of the mask type (55555) are unaffected.
The following example strips out all characters except the hexadecimal digits 0–9 and A-F:
SET str="123$ GYJF870B-QD @#%+"
WRITE $ZSTRIP(str,"*E'N",,"ABCDEF")
returns: 123F870BD