Masking a string in ionic [closed]
I want to mask a string in Ionic-4, the format of the string will be 1234567890987. I want output as 123xxxxxxx987 (i.e) first 3 characters and last 3 characters should be plain and remaining all characters should be masked. Please let me know, how to implement this?
angular ionic-framework hybrid
closed as too broad by Suraj Rao, Owen Pauling, greg-449, Pearly Spencer, Janusz Nov 15 '18 at 14:18
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I want to mask a string in Ionic-4, the format of the string will be 1234567890987. I want output as 123xxxxxxx987 (i.e) first 3 characters and last 3 characters should be plain and remaining all characters should be masked. Please let me know, how to implement this?
angular ionic-framework hybrid
closed as too broad by Suraj Rao, Owen Pauling, greg-449, Pearly Spencer, Janusz Nov 15 '18 at 14:18
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
I want to mask a string in Ionic-4, the format of the string will be 1234567890987. I want output as 123xxxxxxx987 (i.e) first 3 characters and last 3 characters should be plain and remaining all characters should be masked. Please let me know, how to implement this?
angular ionic-framework hybrid
I want to mask a string in Ionic-4, the format of the string will be 1234567890987. I want output as 123xxxxxxx987 (i.e) first 3 characters and last 3 characters should be plain and remaining all characters should be masked. Please let me know, how to implement this?
angular ionic-framework hybrid
angular ionic-framework hybrid
asked Nov 15 '18 at 7:17
user7413163user7413163
1215
1215
closed as too broad by Suraj Rao, Owen Pauling, greg-449, Pearly Spencer, Janusz Nov 15 '18 at 14:18
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by Suraj Rao, Owen Pauling, greg-449, Pearly Spencer, Janusz Nov 15 '18 at 14:18
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Define a function replaceAt
as like this -
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
add a comment |
you can do something like this:
const number:string = "123456789";
const hideMiddleString = (text: string): string =>
if(text.length <= 6)
return text;
const beginString = text.substr(0, 3); // Take 3first chars
const endString = text.substr(-3); // take 3 last chars
// x.repeat will create string of xxxx base on string length - 3 first chars - 3 last chars
return beginString + "x".repeat(text.length - 6) + endString;
;
console.log(hideMiddleString(number));
live sample
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Define a function replaceAt
as like this -
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
add a comment |
Define a function replaceAt
as like this -
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
add a comment |
Define a function replaceAt
as like this -
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
Define a function replaceAt
as like this -
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
function replaceAt(str, pos, value)
var arr = str.split('');
arr[pos]=value;
return arr.join('');
var s = "1234567890987";
for(var i=3;i<s.length-3;i++) s = replaceAt(s, i, 'x');
console.log(s);
answered Nov 15 '18 at 7:41
Harunur RashidHarunur Rashid
1,373713
1,373713
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
add a comment |
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
Thank you for reply. It worked perfectly.
– user7413163
Nov 15 '18 at 9:23
add a comment |
you can do something like this:
const number:string = "123456789";
const hideMiddleString = (text: string): string =>
if(text.length <= 6)
return text;
const beginString = text.substr(0, 3); // Take 3first chars
const endString = text.substr(-3); // take 3 last chars
// x.repeat will create string of xxxx base on string length - 3 first chars - 3 last chars
return beginString + "x".repeat(text.length - 6) + endString;
;
console.log(hideMiddleString(number));
live sample
add a comment |
you can do something like this:
const number:string = "123456789";
const hideMiddleString = (text: string): string =>
if(text.length <= 6)
return text;
const beginString = text.substr(0, 3); // Take 3first chars
const endString = text.substr(-3); // take 3 last chars
// x.repeat will create string of xxxx base on string length - 3 first chars - 3 last chars
return beginString + "x".repeat(text.length - 6) + endString;
;
console.log(hideMiddleString(number));
live sample
add a comment |
you can do something like this:
const number:string = "123456789";
const hideMiddleString = (text: string): string =>
if(text.length <= 6)
return text;
const beginString = text.substr(0, 3); // Take 3first chars
const endString = text.substr(-3); // take 3 last chars
// x.repeat will create string of xxxx base on string length - 3 first chars - 3 last chars
return beginString + "x".repeat(text.length - 6) + endString;
;
console.log(hideMiddleString(number));
live sample
you can do something like this:
const number:string = "123456789";
const hideMiddleString = (text: string): string =>
if(text.length <= 6)
return text;
const beginString = text.substr(0, 3); // Take 3first chars
const endString = text.substr(-3); // take 3 last chars
// x.repeat will create string of xxxx base on string length - 3 first chars - 3 last chars
return beginString + "x".repeat(text.length - 6) + endString;
;
console.log(hideMiddleString(number));
live sample
answered Nov 15 '18 at 7:37
Yanis-gitYanis-git
2,4341724
2,4341724
add a comment |
add a comment |