使用 \k 记事本 ++ 组替换

Notepad ++ group substitutions using \k

如何在 Notepad++ 中使用正则表达式将属于一组的所有项目放在一行中?

我有一组练习题答案,格式如下:

29  Continuous
29  Horizontal mattress
29  Interrupted
29  Vertical mattress
29  No use sutures because the immediate denture acts as a stint
30  1-5 years
30  6-10 years
30  11-15 years
30  16-20 years
30  21-25 years
31  Artery
32  Vitality of the tooth pulp
32  Age of the patient
32  Absence of root resorption

我希望对结果进行格式化,使每组都在一行上:

29 Continuous Horizontal mattress Vertical mattress No use sutures because the immediate denture acts as a stint
30 1-5 years 6-10 years 11-15 years 16-20 years 21-25 years
31 Artery
32 Vitality of the tooth pulp Age of the patient Absence of root resorption

我将以下正则表达式写入 select 集:

^(?'number'^\d{0,4})\t(.*$)(\n\k<number>(.*))*

替换为 得到

29 Continuous   No use sutures because the immediate denture acts as a stint
30 1-5 years    21-25 years
31 Artery 

我做错了什么?

我想出了一个解决方案,以防有人试图做类似的事情。

Select组

(^(?'number'^\d{0,4})\t(.*$)(\n\k<number>(.*))*)

最初发布的代码之间的区别是()整个代码

替换为 \n 以创建以下格式的集合:

29  Continuous
29  Horizontal mattress
29  Interrupted
29  Vertical mattress
29  No use sutures because the immediate denture acts as a stint

30  1-5 years
30  6-10 years
30  11-15 years
30  16-20 years
30  21-25 years

31  Artery

32  Vitality of the tooth pulp
32  Age of the patient
32  Absence of root resorption

Select 带有

的个别行
(^(?'number'^\d{0,4})\t(.*$))\n

替换为 </code>(\3 后的两个空格)以创建 </p> <pre><code>Continuous Horizontal mattress Interrupted Vertical mattress No use sutures because the immediate denture acts as a stint 1-5 years 6-10 years 11-15 years 16-20 years 21-25 years Artery Vitality of the tooth pulp Age of the patient Absence of root resorption

我不知道如何使用正则表达式将问题 #s 添加回来,但如果需要,可以轻松将其导入 excel 以执行此操作。