Skip to main content
original version didn't actually work; a fix would cost a byte
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 2122 16 bytes

T`|`)`\d\|+
\|
(

Try it online! Link includes test cases. Explanation:

T`|`)`\d\|+

Replace all |s that appear after digits with )s.

\|
(

Replace the remaining |s with (s.

Retina 0.8.2, 21 16 bytes

T`|`)`\d\|+
\|
(

Try it online! Link includes test cases. Explanation:

T`|`)`\d\|+

Replace all |s that appear after digits with )s.

\|
(

Replace the remaining |s with (s.

Retina 0.8.2, 22 16 bytes

T`|`)`\d\|+
\|
(

Try it online! Link includes test cases. Explanation:

T`|`)`\d\|+

Replace all |s that appear after digits with )s.

\|
(

Replace the remaining |s with (s.

added 97 characters in body
Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 2121 16 bytes

+`\|(.*?[\d)]T`|`)`\d\|+
\|
($1)

Try it online!Try it online! Link includes test cases. Explanation: Port of @Arnauld's JavaScript answer

T`|`)`\d\|+

Replace all |s that appear after digits with )s.

\|
(

Replace the remaining |s with (s.

Retina 0.8.2, 21 bytes

+`\|(.*?[\d)])\|
($1)

Try it online! Link includes test cases. Explanation: Port of @Arnauld's JavaScript answer.

Retina 0.8.2, 21 16 bytes

T`|`)`\d\|+
\|
(

Try it online! Link includes test cases. Explanation:

T`|`)`\d\|+

Replace all |s that appear after digits with )s.

\|
(

Replace the remaining |s with (s.

Source Link
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 21 bytes

+`\|(.*?[\d)])\|
($1)

Try it online! Link includes test cases. Explanation: Port of @Arnauld's JavaScript answer.