3 sed used is the GNU flavor

# sedGNU sed, 3735 31 bytes (30 +1 for -r argument)

Pure linux sed solution

:;s/([^(])([^()].*)$/\1(\2)/;t  1. Naming the subsitution :; then calling it recursively with t 2. Making 2 regex groups: • First group is first char of two consecutive characters which are not parenthesis • Second group is the second consecutive character and the rest of the string until end of line 3. Add parenthesis around the second group \1 ( \2 ) Edit: Thanks to @manatwork for helping removing 4 characters! Online tester # sed, 3735 31 bytes (30 +1 for -r argument) Pure linux sed solution :;s/([^(])([^()].*)$/\1(\2)/;t

1. Naming the subsitution :; then calling it recursively with t
2. Making 2 regex groups:
• First group is first char of two consecutive characters which are not parenthesis
• Second group is the second consecutive character and the rest of the string until end of line
3. Add parenthesis around the second group \1 ( \2 )

Edit: Thanks to @manatwork for helping removing 4 characters!

Online tester

# GNU sed, 3735 31 bytes (30 +1 for -r argument)

Pure linux sed solution

:;s/([^(])([^()].*)$/\1(\2)/;t  1. Naming the subsitution :; then calling it recursively with t 2. Making 2 regex groups: • First group is first char of two consecutive characters which are not parenthesis • Second group is the second consecutive character and the rest of the string until end of line 3. Add parenthesis around the second group \1 ( \2 ) Edit: Thanks to @manatwork for helping removing 4 characters! Online tester 2 Removed 3rd unecessary regex group, and fix characters count # sed, 36373435 31 bytes (30 +1 for -r argument) Pure linux sed solution :;s/([^(])([^()])(.*)$/\1(\2\3\2)/;t

1. Naming the subsitution :; then calling it recursively with t
2. Making 32 regex groups:
• First and second groups aregroup is first char of two consecutive characters which are not parenthesis
• ThirdSecond group is the second consecutive character and the rest of the string until the end of line
3. Add parenthesis around the second charactergroup \1 ( \2 ) \3

Online testerEdit: Thanks to @manatwork for helping removing 4 characters!

Online tester

# sed, 3634 bytes

Pure linux sed solution

:;s/([^(])([^()])(.*)$/\1(\2\3)/;t  1. Naming the subsitution :; then calling it recursively with t 2. Making 3 regex groups: • First and second groups are two consecutive characters which are not parenthesis • Third group is the rest of the string until the end of line 3. Add parenthesis around the second character \1 ( \2 ) \3 Online tester # sed, 3735 31 bytes (30 +1 for -r argument) Pure linux sed solution :;s/([^(])([^()].*)$/\1(\2)/;t

1. Naming the subsitution :; then calling it recursively with t
2. Making 2 regex groups:
• First group is first char of two consecutive characters which are not parenthesis
• Second group is the second consecutive character and the rest of the string until end of line
3. Add parenthesis around the second group \1 ( \2 )

Edit: Thanks to @manatwork for helping removing 4 characters!

Online tester

1

# sed, 36 34 bytes

Pure linux sed solution

:;s/([^(])([^()])(.*)\$/\1(\2\3)/;t

1. Naming the subsitution :; then calling it recursively with t
2. Making 3 regex groups:
• First and second groups are two consecutive characters which are not parenthesis
• Third group is the rest of the string until the end of line
3. Add parenthesis around the second character \1 ( \2 ) \3

Online tester