如何从记事本中的文本文件中删除换行符和数字

问题描述 投票:1回答:1

我有一些问题保存为.txt文件。我想从它的选项中删除所有问题编号和换行符,并在TAB空间中添加问题。就像一个QUESTION<tab_space>OPTION1<tab_space>OPTION2<tab_space>OPTION3<tab_space>OPTION4然后换行和下一个问题。

我的文本文件看起来像:

11. Lungs are located in the
A) abdominal cavity
B) pericardial cavity
C) peritoneal cavity 
D) pleural cavity
12. Which one of the following is the ideal food for newborn babies?
A) Water
C) Honey
B) Sugar
D) Milk
13. Transcription means the synthesis of
A) Lipids
C) DNA
B) Protein
D) RNA

我怎么想这是:

Lungs are located in the    abdominal cavity    pericardial cavity  peritoneal cavity   pleural cavity
Which one of the following is the ideal food for newborn babies?    Water   Honey   Sugar   Milk
Transcription means the synthesis of    Lipids  DNA Protein RNA

我这样做是因为,我可以只复制所有并粘贴在EXCEL文档上,其中TAB识别为下一行,LINE_BREAK识别为下一列。轻松复制给我。我只是想知道如何用记事本替换单词,不知道如何删除换行符或这些数字以点结尾(。)

我的目标:

  1. 删除所有换行符
  2. 用换行符替换所有带点(。)的数字[11.]
  3. 用TAB空格替换[A-D]和')'
excel notepad
1个回答
0
投票

我们可以通过两个替换来做到这一点:

Find: (?:^|(?<=\n))\d+\.
Replace: (empty)

Demo

Find: (?:^|\r?\n)[A-Z]+\)
Replace: \t

Demo

这是一个Java demo显示更换工作。

© www.soinside.com 2019 - 2024. All rights reserved.