• Login
Community
  • Login

Putting numbers in parentheses

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 1.9k Views
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.
  • V
    Viktoria Ontapado
    last edited by Nov 21, 2017, 5:40 AM

    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

    S 1 Reply Last reply Nov 21, 2017, 12:42 PM Reply Quote 0
    • S
      Scott Sumner @Viktoria Ontapado
      last edited by Nov 21, 2017, 12:42 PM

      @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
      • V
        Viktoria Ontapado
        last edited by Nov 21, 2017, 11:12 PM

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

        1 Reply Last reply Reply Quote 0
        3 out of 3
        • First post
          3/3
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors