how to join multiple lines in notepad++ with comma as a separator

折月煮酒 提交于 2019-12-25 09:45:47

问题


I need to join multiple lines in notepad++ into one single line with comma as a separator

one
two
three
four
five

the output that I need is as below

one,two,three,four,five

Ctrl+A and Ctrl+j will join but will add space


回答1:


CTRL+ H -> check "regular expression" -> search \s\r\n (or \s+ )-> replace all with ,.

Similar question on SuperUser.




回答2:


  • Ctrl+H
  • Find what: \R(?=\S)
  • Replace with: ,
  • Replace all

Explanation:

\R     : any kind of linebreak
(?=\S) : Positive lookahead, make sure we have a non space character after, to avoid inserting a comma at the end of the string

Result for given example:

one,two,three,four,five


来源:https://stackoverflow.com/questions/42465806/how-to-join-multiple-lines-in-notepad-with-comma-as-a-separator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!