118

我有一个包含如下文本的文本文件:

['22APR2012 23:10', '23APR2012 07:10', 1, 3, 0], ['22APR2012 23:10', '23APR2012 07:20', 1, 3, 0], ['22APR2012 23:15', '23APR2012 06:40', 0, 1, 0], ['22APR2012 
23:15', '23APR2012 06:40', 1, 3, 0], ['22APR2012 23:15', '23APR2012 06:40', 0, 1, 0], ['22APR2012 23:15', '23APR2012 07:00', 1, 3, 0], ['22APR2012 23:15', '23APR2012 
07:00', 0, 1, 0], ['22APR2012 23:20', '23APR2012 09:35', 0, 1, 0], ['22APR2012 23:20', '23APR2012 09:35', 1, 3, 0], ['22APR2012 23:20', '23APR2012 10:10', 1, 3, 0], 
['22APR2012 23:25', '23APR2012 05:35', 1, 3, 0], 

我希望在],字符处换行:

['22APR2012 19:30', '23APR2012 00:25', 0, 1, 0], 
['22APR2012 19:35', '23APR2012 01:45', 1, 3, 0],
['22APR2012 19:50', '23APR2012 05:25', 1, 3, 0],
['22APR2012 19:50', '23APR2012 05:25', 0, 1, 0],
['22APR2012 19:55', '23APR2012 06:25', 1, 3, 0],

有没有办法在 Notepad++ 或任何其他编辑器中做到这一点?

4

6 回答 6

205
  1. 单击顶部菜单上的 Ctrl + h 或搜索 -> 替换
  2. 在搜索模式组下,选择正则表达式
  3. 在查找内容文本字段中,键入],\s*
  4. 在替换为文本字段中,键入],\n
  5. 点击全部替换
于 2012-05-19T19:13:11.573 回答
24

Let's assume ], is the character where we wanted to break at

  1. Open notePad++
  2. Open Find window Ctrl+F
  3. Switch to Replace Tab
  4. Choose Search Mode to Extended
  5. Type ], in Find What field
  6. Type \nin Replace with field
  7. Hit Replace All
  8. Boom
于 2016-12-11T10:01:37.940 回答
12

Try this way. It got worked for me

  1. Open Notepad++ then copy your content
  2. Press ctrl + h
  3. Find what is should be ,(comma) or any character that you want to replace
  4. Replace with should be \n
  5. Select Search Mode -> Extended (\n, \r, \t, \0)
  6. Then Click on Replace All
于 2018-03-15T07:07:39.430 回答
10

如果文本包含需要转换为新行的\r\n ,请使用“扩展”或“正则表达式”模式并转义“查找内容”中的反斜杠字符:

查找内容:\\r\\n

Replace with: \r\n

于 2013-05-02T10:19:45.363 回答
2

我不知道它是如何自动工作的,但你可以复制“],”和换行,然后使用替换功能。

于 2012-05-19T19:12:53.113 回答
2

If you are looking to get a comma separated string into a column with CR LF you wont be able to do that in Notepad++, assuming you didn't want to write code, you could manipulate it in Microsoft Excel.

If you copy your string to location B1:

A2 =LEFT(B1,FIND(",",B1)-1)
B2 =MID(B1,FIND(",",B1)+1,10000)

Select A2 and B2, copy the code to successive cells (by dragging):

A3 =LEFT(B2,FIND(",",B2)-1)
B3 =MID(B2,FIND(",",B2)+1,10000)

When you get #VALUE! in the last cell of column A replace it with the previous rows B value.

In the end your A column will contain the desired text. Copy and past it anywhere you wish.

于 2013-05-07T16:50:59.183 回答