Skip to content

trim, ltrim, rtrim

Remove leading or trailing nulls from a list

 trim x     trim[x]
ltrim x    ltrim[x]
rtrim x    rtrim[x]

Where x is a vector or non-null atom, returns x without leading (ltrim) or trailing (rtrim) nulls or without either (trim).

q)trim "   IBM   "
"IBM"
q)trim 0N 0N 1 2 3 0N 0N  4 5 0N 0N
1 2 3 0N 0N 4 5

q)ltrim"   IBM   "
"IBM   "

q)rtrim"   IBM   "
"   IBM"

q)trim"a"
"a"
q)trim 42
42

Drop
Strings