Created
July 30, 2019 12:58
-
-
Save ppsirius/ccef56ee851e4a0b81a4d8f1007e58c6 to your computer and use it in GitHub Desktop.
Mask letters without first and last 3 characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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