Reputation: 429
I have multiple strings containing sql queries that outputs with \n and \t symbols in my logs.
Here is one for example
SELECT id, codcom, action, dc, tc FROM\n\t\t\t\t(SELECT\n\t\t\t\t\tid, codcom, action, dc, tc\n\t\t\t\tFROM\n\t\t\t\t\tattendance.inout\n\t\t\t\tWHERE\n\t\t\t\t\tdc between '2021-10-25' and '2021-10-31' and cod_ditta = 1 and codcom = 6293\n\t\t\t\tUNION\n\t\t\t\tSELECT\n\t\t\t\t\tid, codcom, action, dc, tc\n\t\t\t\tFROM\n\t\t\t\t\tattendance.inout_timb_ext\n\t\t\t\tWHERE\n\t\t\t\t\tdc between '2021-10-25' and '2021-10-31' and cod_ditta = 1 and codcom = 6293) timbs\n\t\t\t\tORDER BY dc , tc
is it possible to use a single regex to replace all the symbols that starts with the backslash symbol with a new line, tab, etcetera?
I know I could achieve the same result with multiple replaces. This question is more out of curiosity.
What I tried so far
So far I was able to select all the symbols that I want to replace with the regex (in the find
section)
\\(\w)
But when it comes to replace I don't know how to replace it with the actual new line, tab, etc.
I tried this so far (in the replace
section), without achieving the desired result:
\\$1
\\1
Upvotes: 1
Views: 864
Reputation: 1396
Not possible with \1
because the group will capture the \\t
which is treated literally and is not \t
(tab
).
In sublime text, do it in two steps, use below expressions:
Step 1:
(\\t)
(space)Step 2:
(\\t)
\n
(newline)Upvotes: 1