Hello, Hi, @tư-mã-tần-quảng and All,
I forgot to explain my regex S/R :
SEARCH (?s-i)(\h+<name>.+?)(\h+<id>.+?\R)
REPLACE \2\1
So :
First, the part (?s-i) has already been explained by @alan-kilborn !
Then, the part \h+<name> searches for some horizontal blank characters, followed with the string <name>, with this exact case
Now, the part .+?, due to the s modifier, looks for the shortest non-null range of any char, even EOL ones, till … some blank chars, again, followed with the string <id>, with this exact case
The two parts above are stored as group 1 because of the surrounding parentheses. Note that it, necessarily, ends with EOL chars, as followed with the <id> line !
Then the part \h+<id> matches any horizontal blank chars, followed with the string <id>, with this exact case
Finally, the part .+?\R matches the shortest non-null range of any char till… the next EOL chars, so ending the <id> line
Again, the two parts above are stored as group 2 because of the surrounding parentheses.
Note that the \R syntax stands for any kind of line-break ( \r\n for Windows files, \n for Unix files and \r for Mac files )
In replacement, the \2\1 rewrites, in reverse order, the single-line group 2 ( line <id> ) and the multi-lines group 1
Best Regards,
guy038