Masking a string in ionic [closed]










0















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?










share|improve this 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.






















    0















    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?










    share|improve this 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.




















      0












      0








      0


      0






      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      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.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          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);








          share|improve this answer























          • Thank you for reply. It worked perfectly.

            – user7413163
            Nov 15 '18 at 9:23


















          0














          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






          share|improve this answer





























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            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);








            share|improve this answer























            • Thank you for reply. It worked perfectly.

              – user7413163
              Nov 15 '18 at 9:23















            0














            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);








            share|improve this answer























            • Thank you for reply. It worked perfectly.

              – user7413163
              Nov 15 '18 at 9:23













            0












            0








            0







            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);








            share|improve this answer













            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);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            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

















            • 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













            0














            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






            share|improve this answer



























              0














              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






              share|improve this answer

























                0












                0








                0







                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






                share|improve this answer













                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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 7:37









                Yanis-gitYanis-git

                2,4341724




                2,4341724













                    Popular posts from this blog

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Syphilis

                    Darth Vader #20