Move all text between two "\t" in Notepad++
I have more than a million lines of text in this format:
AAAA BBBBBBBBBBBBBBB CCCC
Separated by \t
I want to have it in a format
AAAA_CCCC BBBBBBBBBBBBBBB
But I cannot seem to figure out how to do it using regular expressions in Notepad++
You may try the following find and replace, in regex mode:
Find: ^(\S+)\t(\S+)\t(\S+)$
Replace: $1_$3 $2
Here is a demo.
If the separator is a tab, you can use
^[^\r\n\t]+\K\t([^\r\n\t]+)\t([^\r\n\t]+)$
The pattern matches:
-
^
Start of string -
[^\r\n\t]+
Match 1+ chars other than a tab or newline -
\K\t
Forget what is matches so far using\K
and match a tab -
([^\r\n\t]+)
Capture group 1, match any 1+ chars other than a newline or tab -
\t
Match a tab -
([^\r\n\t])
Capture group 2, match 1 char other than a newline or tab -
$
end of string
In the replacement use the 2 capture groups with an underscore in between.
_$2 $1
See a regex demo.
The result of the replacement:
AAAA_CCCC BBBBBBBBBBBBBBB