Putting numbers in parentheses
-
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 2I’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 -
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!] -
Thank you so much for the solution and explanation Scott, I really appreciate it.
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