Skip to content

Instantly share code, notes, and snippets.

@ppsirius
Created July 30, 2019 12:58
Show Gist options
  • Save ppsirius/ccef56ee851e4a0b81a4d8f1007e58c6 to your computer and use it in GitHub Desktop.
Save ppsirius/ccef56ee851e4a0b81a4d8f1007e58c6 to your computer and use it in GitHub Desktop.
Mask letters without first and last 3 characters
const maskString = data => {
const firstThreeChar = /(^.{3})/g
const lastThreeChar = /(.{3}$)/g
const maskedString = data.replace(/./g, String.fromCharCode(32, 183, 32)).slice(6)
return data.match(firstThreeChar) + maskedString + data.match(lastThreeChar)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment