1

I'm trying to put parenthesis around every character and brackets around every line using Regex in Sublime Text (actually, I don't mind which flavor, because I can always use regex101).

I want to do this in one go. I can do this in two steps, but is it possible in one?

My input:

awKJ38W3i

My goal output:

(a)(w)(K)(J){3}{8}(W){3}(i)

What I've done so far:

I've been able to create two groups, 1 and 2, which match characters and numbers:

([A-z])|([0-9])

([A-z]) : Matches individual alpha characters and set as group 1
|       : OR
([0-9]) : Matches individual numeric characters and set as group 2

Now the problem is during the replacing. I want to replace the [A-z] with \($1\) and the [0-9] with \{$1\} but simultaneously. How can I do this?

I tried replacing it with

\($1\)|\{$2\}

but that doesn't seem to be the correct syntax.

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
zec
  • 31
  • 3

0 Answers0