SQLite 3 reference · String Functions
SQLite TRIM() Function
Remove spaces, or any characters you list, from both ends of a string. Spaces inside the string are kept.
SQLite 3
Syntax
trim(X, Y)
Parameters
| Parameter | Description |
|---|---|
X |
The string (other values are converted to text). |
Y optional |
The characters to remove; spaces by default. |
Return value
The trimmed string.
Examples
SELECT '[' || trim(' hello ') || ']' AS trimmed;
Output
trimmed [hello]
SELECT trim('--==Title==--', '-=') AS title,
trim('007', '0') AS no_zeros;
Output
title | no_zeros Title | 7
In other languages
TRIM()· PostgreSQL
Related
LTRIM()· Remove spaces, or characters you list, from the start (left side) of a string only.RTRIM()· Remove spaces, or characters you list, from the end (right side) of a string only.REPLACE()· Replace every occurrence of one string with another inside a string. The search is case-sensitive.- SQL String Functions · tutorial