我正在尝试使用正则表达式从更改日志中提取数据。以下是更改日志的结构示例:
96545
this is some changes in the ticket
some new version: x.x.22
another change
new version: x.y.2.2
120091
this is some changes in the ticket
some new version: z.z.22
another change
another change
another change
new version: z.y.2.2
120092
...
...
...
- 每个数据点都以 ID 开头,ID 范围为 5 到 6 位数字。
- 此外,每个 ID 的日志中的更改量(行)都是可变的。
- 每个数据点均以
新版本:***
结尾。***
是每个 ID 都可变的字符串。
我正在使用 RegExStrom Tester测试我的正则表达式。
到目前为止,我有: ^\w{5,6}(.|\n)*?\d{5,6}
但是结果包括下一张票的 ID,其中我需要避免。
结果:
96545
this is some changes in the ticket
some new version: x.x.22
another change
new version: x.y.2.2
120091
预期结果:
96545
this is some changes in the ticket
some new version: x.x.22
another change
new version: x.y.2.2
最佳答案
关于python - 如何提取数字之间的字符串? (并保留字符串中的第一个数字?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58240959/