Removing caret sign and adding parentheses to pager numbers

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I have strings like these



NE234GJKLKU,*9^789098
NE345HJsdfe,*1^534656
YBKJNJKHBKK,*1^987654
UTGHNKOIUYO,*1^123421
ERTYUIJHGLK,*1^456666


that I wish to be:



NE234GJKLKU,*(978)-9098
NE345HJsdfe,*(153)-4656
YBKJNJKHBKK,*(198)-7654
UTGHNKOIUYO,*(112)-3421
ERTYUIJHGLK,*(145)-6666


Any suggestions?










share|improve this question









New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Sorry, should be correct now!
    – Cumar
    3 hours ago














up vote
3
down vote

favorite












I have strings like these



NE234GJKLKU,*9^789098
NE345HJsdfe,*1^534656
YBKJNJKHBKK,*1^987654
UTGHNKOIUYO,*1^123421
ERTYUIJHGLK,*1^456666


that I wish to be:



NE234GJKLKU,*(978)-9098
NE345HJsdfe,*(153)-4656
YBKJNJKHBKK,*(198)-7654
UTGHNKOIUYO,*(112)-3421
ERTYUIJHGLK,*(145)-6666


Any suggestions?










share|improve this question









New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



















  • Sorry, should be correct now!
    – Cumar
    3 hours ago












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I have strings like these



NE234GJKLKU,*9^789098
NE345HJsdfe,*1^534656
YBKJNJKHBKK,*1^987654
UTGHNKOIUYO,*1^123421
ERTYUIJHGLK,*1^456666


that I wish to be:



NE234GJKLKU,*(978)-9098
NE345HJsdfe,*(153)-4656
YBKJNJKHBKK,*(198)-7654
UTGHNKOIUYO,*(112)-3421
ERTYUIJHGLK,*(145)-6666


Any suggestions?










share|improve this question









New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have strings like these



NE234GJKLKU,*9^789098
NE345HJsdfe,*1^534656
YBKJNJKHBKK,*1^987654
UTGHNKOIUYO,*1^123421
ERTYUIJHGLK,*1^456666


that I wish to be:



NE234GJKLKU,*(978)-9098
NE345HJsdfe,*(153)-4656
YBKJNJKHBKK,*(198)-7654
UTGHNKOIUYO,*(112)-3421
ERTYUIJHGLK,*(145)-6666


Any suggestions?







text-processing






share|improve this question









New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









Arkadiusz Drabczyk

7,40521633




7,40521633






New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









Cumar

184




184




New contributor




Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Cumar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • Sorry, should be correct now!
    – Cumar
    3 hours ago
















  • Sorry, should be correct now!
    – Cumar
    3 hours ago















Sorry, should be correct now!
– Cumar
3 hours ago




Sorry, should be correct now!
– Cumar
3 hours ago










3 Answers
3






active

oldest

votes

















up vote
4
down vote



accepted










try sed



sed -r -e 's/^//g;s/^.13/&(/;s/^.17/&)-/' file

NE234GJKLKU,*(978)-9098
NE345HJsdfe,*(153)-4656
YBKJNJKHBKK,*(198)-7654
UTGHNKOIUYO,*(112)-3421
ERTYUIJHGLK,*(145)-6666





share|improve this answer




















  • thank you for helping me
    – Cumar
    3 hours ago

















up vote
1
down vote













I think this will do:



sed -E 's/(.)^(..)/(12)-/' file





share|improve this answer



























    up vote
    0
    down vote













    Another sed solution:



    $ sed 's,*,*(,g' FILE | sed -E 's,([0-9])^([b0-9])([0-9]),123)-,g'
    NE234GJKLKU,*(978)-9098
    NE345HJsdfe,*(153)-4656
    YBKJNJKHBKK,*(198)-7654
    UTGHNKOIUYO,*(112)-3421
    ERTYUIJHGLK,*(145)-6666


    Single line:



    $ sed -E 's,*,*(,g;s,([0-9])^([b0-9])([0-9]),123)-,g' FILE
    NE234GJKLKU,*(978)-9098
    NE345HJsdfe,*(153)-4656
    YBKJNJKHBKK,*(198)-7654
    UTGHNKOIUYO,*(112)-3421
    ERTYUIJHGLK,*(145)-6666





    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      Cumar is a new contributor. Be nice, and check out our Code of Conduct.









       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474640%2fremoving-caret-sign-and-adding-parentheses-to-pager-numbers%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      4
      down vote



      accepted










      try sed



      sed -r -e 's/^//g;s/^.13/&(/;s/^.17/&)-/' file

      NE234GJKLKU,*(978)-9098
      NE345HJsdfe,*(153)-4656
      YBKJNJKHBKK,*(198)-7654
      UTGHNKOIUYO,*(112)-3421
      ERTYUIJHGLK,*(145)-6666





      share|improve this answer




















      • thank you for helping me
        – Cumar
        3 hours ago














      up vote
      4
      down vote



      accepted










      try sed



      sed -r -e 's/^//g;s/^.13/&(/;s/^.17/&)-/' file

      NE234GJKLKU,*(978)-9098
      NE345HJsdfe,*(153)-4656
      YBKJNJKHBKK,*(198)-7654
      UTGHNKOIUYO,*(112)-3421
      ERTYUIJHGLK,*(145)-6666





      share|improve this answer




















      • thank you for helping me
        – Cumar
        3 hours ago












      up vote
      4
      down vote



      accepted







      up vote
      4
      down vote



      accepted






      try sed



      sed -r -e 's/^//g;s/^.13/&(/;s/^.17/&)-/' file

      NE234GJKLKU,*(978)-9098
      NE345HJsdfe,*(153)-4656
      YBKJNJKHBKK,*(198)-7654
      UTGHNKOIUYO,*(112)-3421
      ERTYUIJHGLK,*(145)-6666





      share|improve this answer












      try sed



      sed -r -e 's/^//g;s/^.13/&(/;s/^.17/&)-/' file

      NE234GJKLKU,*(978)-9098
      NE345HJsdfe,*(153)-4656
      YBKJNJKHBKK,*(198)-7654
      UTGHNKOIUYO,*(112)-3421
      ERTYUIJHGLK,*(145)-6666






      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 3 hours ago









      Goro

      8,27854282




      8,27854282











      • thank you for helping me
        – Cumar
        3 hours ago
















      • thank you for helping me
        – Cumar
        3 hours ago















      thank you for helping me
      – Cumar
      3 hours ago




      thank you for helping me
      – Cumar
      3 hours ago












      up vote
      1
      down vote













      I think this will do:



      sed -E 's/(.)^(..)/(12)-/' file





      share|improve this answer
























        up vote
        1
        down vote













        I think this will do:



        sed -E 's/(.)^(..)/(12)-/' file





        share|improve this answer






















          up vote
          1
          down vote










          up vote
          1
          down vote









          I think this will do:



          sed -E 's/(.)^(..)/(12)-/' file





          share|improve this answer












          I think this will do:



          sed -E 's/(.)^(..)/(12)-/' file






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 hours ago









          glenn jackman

          48.7k366105




          48.7k366105




















              up vote
              0
              down vote













              Another sed solution:



              $ sed 's,*,*(,g' FILE | sed -E 's,([0-9])^([b0-9])([0-9]),123)-,g'
              NE234GJKLKU,*(978)-9098
              NE345HJsdfe,*(153)-4656
              YBKJNJKHBKK,*(198)-7654
              UTGHNKOIUYO,*(112)-3421
              ERTYUIJHGLK,*(145)-6666


              Single line:



              $ sed -E 's,*,*(,g;s,([0-9])^([b0-9])([0-9]),123)-,g' FILE
              NE234GJKLKU,*(978)-9098
              NE345HJsdfe,*(153)-4656
              YBKJNJKHBKK,*(198)-7654
              UTGHNKOIUYO,*(112)-3421
              ERTYUIJHGLK,*(145)-6666





              share|improve this answer
























                up vote
                0
                down vote













                Another sed solution:



                $ sed 's,*,*(,g' FILE | sed -E 's,([0-9])^([b0-9])([0-9]),123)-,g'
                NE234GJKLKU,*(978)-9098
                NE345HJsdfe,*(153)-4656
                YBKJNJKHBKK,*(198)-7654
                UTGHNKOIUYO,*(112)-3421
                ERTYUIJHGLK,*(145)-6666


                Single line:



                $ sed -E 's,*,*(,g;s,([0-9])^([b0-9])([0-9]),123)-,g' FILE
                NE234GJKLKU,*(978)-9098
                NE345HJsdfe,*(153)-4656
                YBKJNJKHBKK,*(198)-7654
                UTGHNKOIUYO,*(112)-3421
                ERTYUIJHGLK,*(145)-6666





                share|improve this answer






















                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Another sed solution:



                  $ sed 's,*,*(,g' FILE | sed -E 's,([0-9])^([b0-9])([0-9]),123)-,g'
                  NE234GJKLKU,*(978)-9098
                  NE345HJsdfe,*(153)-4656
                  YBKJNJKHBKK,*(198)-7654
                  UTGHNKOIUYO,*(112)-3421
                  ERTYUIJHGLK,*(145)-6666


                  Single line:



                  $ sed -E 's,*,*(,g;s,([0-9])^([b0-9])([0-9]),123)-,g' FILE
                  NE234GJKLKU,*(978)-9098
                  NE345HJsdfe,*(153)-4656
                  YBKJNJKHBKK,*(198)-7654
                  UTGHNKOIUYO,*(112)-3421
                  ERTYUIJHGLK,*(145)-6666





                  share|improve this answer












                  Another sed solution:



                  $ sed 's,*,*(,g' FILE | sed -E 's,([0-9])^([b0-9])([0-9]),123)-,g'
                  NE234GJKLKU,*(978)-9098
                  NE345HJsdfe,*(153)-4656
                  YBKJNJKHBKK,*(198)-7654
                  UTGHNKOIUYO,*(112)-3421
                  ERTYUIJHGLK,*(145)-6666


                  Single line:



                  $ sed -E 's,*,*(,g;s,([0-9])^([b0-9])([0-9]),123)-,g' FILE
                  NE234GJKLKU,*(978)-9098
                  NE345HJsdfe,*(153)-4656
                  YBKJNJKHBKK,*(198)-7654
                  UTGHNKOIUYO,*(112)-3421
                  ERTYUIJHGLK,*(145)-6666






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 3 hours ago









                  Arkadiusz Drabczyk

                  7,40521633




                  7,40521633




















                      Cumar is a new contributor. Be nice, and check out our Code of Conduct.









                       

                      draft saved


                      draft discarded


















                      Cumar is a new contributor. Be nice, and check out our Code of Conduct.












                      Cumar is a new contributor. Be nice, and check out our Code of Conduct.











                      Cumar is a new contributor. Be nice, and check out our Code of Conduct.













                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474640%2fremoving-caret-sign-and-adding-parentheses-to-pager-numbers%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Comments

                      Popular posts from this blog

                      Long meetings (6-7 hours a day): Being “babysat” by supervisor

                      Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                      Confectionery