mjdaran
mjdaran

Reputation: 27

Duplicate a part of the line and add it to the end of the line with a separator

I know it sounds confusing but this is what I want.

ABC@123: to the changed to ABC@123:ABC

Basically, I need to replicate the texts before the "@" and paste it at the end of the line. Is there any command that can be implemented in the Notepadd++ ?? And the file has more than 100K lines, so please suggest me easy solutions.

Thanks in advance.

Upvotes: 0

Views: 506

Answers (1)

Toto
Toto

Reputation: 91430

  • Ctrl+H
  • Find what: ^([^@]+)@.+$
  • Replace with: $0$1
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline
  • Replace all

Explanation:

^           # beginning of line
    ([^@]+)     # group 1, 1 or more any character that is not @
    @           # @ character
    .+          # 1 or more any character
$           # end of line

Replacement:

$0      # the whole match
$1      # content of group 1 (everything before @)

Screenshot (before):

enter image description here

Screenshot (after):

enter image description here

Upvotes: 2

Related Questions