如何使用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我编写了以下regex来选择这些集合:
^(?'number'^\d{0,4})\t(.*$)(\n\k<number>(.*))*用\1 \2 \4给出
29 Continuous No use sutures because the immediate denture acts as a stint
30 1-5 years 21-25 years
31 Artery 我在这里做错什么了?
发布于 2019-09-21 17:29:37
我想出了一个解决办法,以防有人试图做类似的事情。
选择具有
(^(?'number'^\d{0,4})\t(.*$)(\n\k<number>(.*))*)最初发布的代码之间的区别是围绕整个代码的()。
用\1\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选择单独的行
(^(?'number'^\d{0,4})\t(.*$))\n用\3替换(\3之后的两个空格)来创建
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我不知道如何使用regex返回问题#s,但是如果需要的话,它可以很容易地导入到excel中。
https://stackoverflow.com/questions/58020045
复制相似问题