教程 radash tutorial

trim

从字符串中修剪值

基本用法

从给定字符串中修剪所有前缀和后缀字符。类似于内置的trim函数,但接受你想要修剪的替代(非空格)字符。

ts
import { trim } from 'radash'

trim('  hello ') // => hello
trim('__hello__', '_') // => hello
trim('/repos/:owner/', '/') // => repos/:owner

Trim还可以处理多个要修剪的字符。

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