'How can I find why re finditer is missing one item in the search
I have been trying to use re finditer to return four items, however it only return three. How should I modify the search in my re?
1). string:
'''contet_o= "ALIBRA Updated Wednesday (04 May 2022\nA S *Contactus
forrates/chartson scrubber & eco tonnage.\n\nPERIOD\n\nDRY TIME CHARTER
ESTIMATES ($/pdpr)\n\n4/6 MOS\n\nSIZE\nHANDY
(sexaw1)\nSMAX/ULTRA.\nPANA/KMAX\n\nCAPESIZE\n\nATL PAC ATL PAC ATL
PAC\n\n28,500 | 32,000 @ 27,500/ 28,500) 23,000 24,000\n28,500 |32,000 |=
30,250 |= 22,000) 24,500) 19,250\n29,000 | 29,000 26,000/'¥ 26,000) 24,000|—=
24,000\n\n29,500 |31,000 | 28,000 | 28,000/= 24,000/= 24,000\n\n'''
2). search by re:
''' saved_list_1 = re.finditer(r"\n((.*)(\d+\,\d+)){6}\n",contet_o)
list_ddddd = []
for item in saved_list_1:
list_ddddd.append(item.group())
list_ddddd'''
3). It return: (missing the second one)
['\n28,500 | 32,000 @ 27,500/ 28,500) 23,000 24,000\n',
"\n29,000 | 29,000 26,000/'¥ 26,000) 24,000|—= 24,000\n",
'\n29,500 |31,000 | 28,000 | 28,000/= 24,000/= 24,000\n']
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|