# XSTRIP

> [HTML Version](xstrip_sbr.htm)

**xcall XSTRIP, strarg**

**xcall XSTRIP, strarg, filter, opcode**

XSTRIP performs various string editing operations. Note that in the first syntax, the routine is equivalent to XCALL STRIP (removes trailing blanks).

**Parameters**

_strarg_  ([String](string.md), 2+ bytes)  \[in/out\]

the string to be operated on.

_filter_  ([String](string.md), 1+ bytes)  \[in\]

contains filter info, depending on opcode.

_opcode_  ([Num](num.md))  \[in\]

defines the operation.

| **Opcode** | **Function** |
|------|------|
| 1 | All occurrences of any of the individual characters in the filter are removed from _strarg_. |
| 2 | All occurrences of characters NOT in filter are removed from _strarg_. |
| 3 | Remove Words. _filter_ contains a comma-separated list of words to be removed from _strarg_. Double spaces resulting from the removal of a word are shortened to a single space. Example:<br>strarg = "THIS IS A TEST OF THIS XCALL ROUTINE"<br>filter = "THIS,TEST,ROUTINE"<br>XCALL XSTRIP,strarg,filter,3<br>Result: strarg = " IS A OF XCALL " |
| 4 | Removes matching characters from start of string. For example:<br>strarg = "THIS IS A TEST TO SEE WHAT IS HAPPENING."<br>filter = "SIHT "<br>XCALL XSTRIP,strarg,filter,4<br>Result: strarg = "A TEST TO SEE WHAT IS HAPPENING."<br>Note: The removal process was terminated at the first character of _strarg_ for which there was no match in filter ("A"). |
| 5 | Remove matching characters from the end of the string. Same concept as opcode 4 but starts at the end of _strarg_ and works backwards. |
| 6 | Pair-wise character substitution: _filter_ must contain an even number of characters, interpreted as pairs. Each occurrence in _strarg_ of the first character in each pair (of filter) is replaced with the second character of the pair. Example:<br>XCALL XSTRIP,strarg,"A1B2",6   \! replace all "A" with "1"; "B" with "2" |
| 7 | Reduce multiple spaces to single spaces. _filter_ not used. E.g.: XCALL XSTRIP,strarg,"",7 |
| 8 | (not used) |
| 9 | Combines the action of opcodes 4 (strip leading characters) and 5 (strip trailing characters) to make it a simpler alternative to Xcall TRIM when you want to strip something other than spaces and TABs. |




**History**

2024 August, A-Shell 7.0.1762: added opcode 9.

2011 May, A-Shell 5.1.1215:  XSTRIP added to the standard release, after fixing some bugs introduced in 5.1 during translation of the original proprietary version written by John Pruitt.