Masks a portion of a string, replacing the masked characters with a mask character.
将字符串的指定部分替换为掩码字符,用于隐藏敏感信息。
The string to mask. 要掩码的字符串
The masking options. 掩码选项
The masked string. 掩码后的字符串
Indices are UTF-16 code units; a negative end counts from the end of the string. Non-finite start/end values resolve to 0 and value.length respectively.
end
start
value.length
索引按 UTF-16 码元计算;end 为负数时从字符串末尾开始计数。 非有限的 start/end 值分别解析为 0 和 value.length。
mask('13800138000') // => '138****8000' Copy
mask('13800138000') // => '138****8000'
mask('user@example.com', { start: 1, end: 4 }) // => 'u***@example.com' Copy
mask('user@example.com', { start: 1, end: 4 }) // => 'u***@example.com'
mask('12345678', { start: 2, end: -2 }) // => '12****78' Copy
mask('12345678', { start: 2, end: -2 }) // => '12****78'
Masks a portion of a string, replacing the masked characters with a mask character.
将字符串的指定部分替换为掩码字符,用于隐藏敏感信息。