TRIM()

<< | FB 2.0 Language Reference | >>

TRIM()

Available in: DSQL, PSQL

Added in: 2.0

Description

Removes leading and/or trailing spaces (or optionally other strings) from the input string. The result is a VARCHAR(n) with n the formal length of the input string.

Result type: VARCHAR(n)

Syntax

 TRIM ([<adjust>] str)

 <adjust>  ::= {[where] [what]} FROM

 where     ::= BOTH | LEADING | TRAILING /* default is BOTH */

 what      ::= The substring to be removed (repeatedly if necessary)
               from str's head and/or tail. Default is ' ' (space).

Examples

 select trim (' Waste no space ') from rdb$database
   -- returns 'Waste no space'

 select trim (leading from ' Waste no space ') from rdb$database
   -- returns 'Waste no space '

 select trim (leading '.' from ' Waste no space ') from rdb$database
   -- returns ' Waste no space '

 select trim (trailing '!' from 'Help!!!!') from rdb$database
   -- returns 'Help'

 select trim ('la' from 'lalala I love you Ella') from rdb$database
   -- returns ' I love you El'

 select trim ('la' from 'Lalala I love you Ella') from rdb$database
   -- returns 'Lalala I love you El'

See also:
RPAD()
LPAD()
Firebird Null Guide: Internal functions and directives
Firebird 2.0.4 Release Notes: New features for text data

back to top of page
<< | FB 2.0 Language Reference | >>