Community
    • Login

    Putting numbers in parentheses

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 2.2k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Viktoria OntapadoV Offline
      Viktoria Ontapado
      last edited by

      Hello,
      I’d like to request a bit of help with the following.

      I have a file with only number combinations. Sometimes I have multiple combinations per line and the combos are separated by semi-colons.

      Sample of the file:

      4 2 1 5
      3 3 0 4
      10 7 12 4
      0 0 0 6
      0 2 3 1; 3 7 9 9; 4 11 12 4
      2 3 3 6; 8 17 1 0
      3 0 0 0
      12 12 15 7; 3 3 6 9; 21 5 2 8; 0 1 0 1
      3 5 5 7; 9 12 3 4
      2 5 8 1
      3 4 7 2

      I’d like to modify it so that every number will be placed inside brackets.

      It should be displayed as:

      (4) (2) (1) (5)
      (3 (3) (0) (4)
      (10 (7) (12) (4)
      (0) (0) (0) (6)
      (0) (2) (3) (1); (3) (7) (9) (9); (4) (11) (12) (4)
      (2 (3) (3) (6); (8) (17) (1) (0)
      (3 (0) (0) (0)
      (12) (12) (15) (7); (3) (3) (6) (9); (21) (5) (2) (8); (0) (1) (0) (1)
      (3) (5) (5) (7); (9) (12) (3) (4)
      (2) (5) (8) (1)
      (3) (4) (7) (2)

      How can I achieve this?

      Thank you,
      Viktória

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS Offline
        Scott Sumner @Viktoria Ontapado
        last edited by

        @Viktoria-Ontapado

        Use:

        Find-what zone: (\d+)
        Replace-with zone: \(\1\)

        This is a good opportunity to point out that literal ( and ) used in the Replace-with zone need escaping with the \ before them. [Escaping is also needed for them to appear literally in the Find-what zone, but that is more well-known!]

        1 Reply Last reply Reply Quote 0
        • Viktoria OntapadoV Offline
          Viktoria Ontapado
          last edited by

          Thank you so much for the solution and explanation Scott, I really appreciate it.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors