Skip to content

trim

Trim values from a string

150 bytes

Usage

Trims all prefix and suffix characters from the given string. Like the builtin trim function but accepts alternate (other than space) characters you would like to trim.

import * as
import _
_
from 'radashi'
import _
_
.
function trim(str: string | null | undefined, charsToTrim?: string): string
export trim

Trims all prefix and suffix characters from the given string. Like the builtin trim function but accepts other characters you would like to trim and trims multiple characters.

@seehttps://radashi.js.org/reference/string/trim

@example

trim(' hello ') // => 'hello'
trim('__hello__', '_') // => 'hello'
trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
trim('222222__hello__1111111', '12_') // => 'hello'

@version12.1.0

trim
(' hello ') // => hello
import _
_
.
function trim(str: string | null | undefined, charsToTrim?: string): string
export trim

Trims all prefix and suffix characters from the given string. Like the builtin trim function but accepts other characters you would like to trim and trims multiple characters.

@seehttps://radashi.js.org/reference/string/trim

@example

trim(' hello ') // => 'hello'
trim('__hello__', '_') // => 'hello'
trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
trim('222222__hello__1111111', '12_') // => 'hello'

@version12.1.0

trim
('__hello__', '_') // => hello
import _
_
.
function trim(str: string | null | undefined, charsToTrim?: string): string
export trim

Trims all prefix and suffix characters from the given string. Like the builtin trim function but accepts other characters you would like to trim and trims multiple characters.

@seehttps://radashi.js.org/reference/string/trim

@example

trim(' hello ') // => 'hello'
trim('__hello__', '_') // => 'hello'
trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
trim('222222__hello__1111111', '12_') // => 'hello'

@version12.1.0

trim
('/repos/:owner/', '/') // => repos/:owner

Trim also handles more than one character to trim.

import _
_
.
function trim(str: string | null | undefined, charsToTrim?: string): string
export trim

Trims all prefix and suffix characters from the given string. Like the builtin trim function but accepts other characters you would like to trim and trims multiple characters.

@seehttps://radashi.js.org/reference/string/trim

@example

trim(' hello ') // => 'hello'
trim('__hello__', '_') // => 'hello'
trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
trim('222222__hello__1111111', '12_') // => 'hello'

@version12.1.0

trim
('222__hello__111', '12_') // => hello