dvazantunes
dvazantunes

Reputation: 41

Merge all lines into one on notepad++

I have the following list:

32229_071
32225_041
32225_011
32225_011
32225_011

I want it to look like

'32229_071','32225_041','32225_011','32225_011','32225_011'

How do I do this in Notepad++?

Upvotes: 1

Views: 338

Answers (2)

Toto
Toto

Reputation: 91518

  • Ctrl+H
  • Find what: (?:^|\G)(.+)(?:(\R)|\z)
  • Replace with: '$1'(?2,:)
  • CHECK Wrap around
  • CHECK Regular expression
  • UNCHECK . matches newline*
  • Replace all

Explanation:

(?:^|\G)        # non capture group, beginning of line or restart from last match position
(.+)            # group 1, 1 or more any character but newline
(?:             # non capture group
  (\R)          # group 2, any kind of linebreak
 |              # OR
  \z            # end of file
)               # end group

Replacement:

'$1'            # content of grop 1  between single quotes
(?2,:)          # conditional replace, if group 2 exists then a comma else nothing

Screen capture (before):

enter image description here

Screen capture (after):

enter image description here

Upvotes: 2

Jannick Breunis
Jannick Breunis

Reputation: 345

  1. Go to replace (ctrl+h)
  2. Search for \r\n
  3. Replace ,
  4. Check Extended (left bottom)
  5. Add first and last quote

And replace!

enter image description here

Upvotes: 0

Related Questions