Skip to content

@pmun/utils / replaceNBSP

Function: replaceNBSP() ​

ts
function replaceNBSP(str?): string;

替换字符串中的   为不换行空格

Parameters ​

str? ​

string

字符串,省略时返回 undefined

Returns ​

string

处理后的字符串;非字符串输入原样返回

Example ​

ts
// 基本用法
replaceNBSP('John Doe') // 'John Doe'
replaceNBSP('Jane  Smith') // 'Jane  Smith'
replaceNBSP('Smith') // 'Smith'