# TRIM

Updated: 11/30/2021, 7:00:45 PM
Created: 11/30/2021, 7:00:45 PM
Last Updated By: Jake Tuttle
Read Time: 1 minute(s)

# Description

The TRIM function allows characters to be removed from a string in a number of ways. It takes the general form:

TRIM(expression1 {, expression2{, type}})
1

Where:

expression1 specifies the string from which to trim characters.

expression2 may optionally specify the character to remove from the string. If not specified then the space character is assumed.

The type of the TRIM() function can be one of the following single letters:

Type Operation
L removes leading characters only
T removes trailing characters only
B removes leading and trailing characters
A removes all occurrences of the character
R removes leading, trailing and redundant characters
F removes leading spaces and tabs
E removes trailing spaces and tabs
D removes leading, trailing and redundant spaces and tabs.

Type is case insensitive (effective as of jBASE 5.8).

An example of use is as:

INPUT ANS
ANS = TRIM (ANS," ","D")
1
2

or:

INPUT ANS
ANS = TRIM(ANS)
1
2

to remove spaces and tabs. Note the second parameter is ignored in the first code sample.

Go back to jBASE BASIC

Go back to Programmers' Reference Guide