Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hideData(array){
- let nameRegex = /\*[A-Z][A-Za-z]+(?=\s|$)/g;
- let phoneNumberRegex = /\+[0-9-]{10}(?=\s|$)/g;
- let idRegex = /![a-zA-Z0-9]+(?=\s|$)/g;
- let nameOfBaseRegex =/_[0-9A-Za-z]+(?=\s|$)/g;
- let result = [];
- for(let sentence of array){
- let match =
- sentence.match(nameRegex)
- ||sentence.match(phoneNumberRegex)
- ||sentence.match(idRegex)
- ||sentence.match(nameOfBaseRegex) ;
- while(match != null) {
- for (let secret of match) {
- let hidden = '|'.repeat(secret.length);
- sentence = sentence.replace(secret,hidden);
- }
- match =
- sentence.match(nameRegex)
- ||sentence.match(phoneNumberRegex)
- ||sentence.match(idRegex)
- ||sentence.match(nameOfBaseRegex) ;
- }
- result.push(sentence);
- }
- console.log(result.join('\n'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement