I have a file like this. The format of the version is <version> space(s) dash space(s) date. I want to create a dictionary with 4.11.1 - 2020-02-25 as key and everything after that before 3.25.0 - 2019-01-01 as value and so on till the end of the file.
##################
Some texts
4.11.1 - 2020-02-25
-------------------
*some text
** Some more text
3.25.0 - 2019-01-01
-------------------
*some text
** Some more text
This is what I tried:
result ={}
matches = re.findall(r'([\d.]+[^\n]+)\s*(.*?)(?=\s*[\d.]+[^\n]+|$)', Text, re.S)
for match in matches:
result[match[0]] = match[1]
print(result)
It works for most of the cases. But it also prints these as keys :
.com/sth/sth/sth/6)
1.8.2 (https://github.com/sth/sth/sth/5)
1.8.1.
20160918 (see commands under 'some text')
. text text tex
^(\d+(?:\.\d+)+ - \d{4}-\d{2}-\d{2})\r?\n((?:(?!\d+\.\d).*(?:\r?\n|$))*)regex101.com/r/dxEkrg/1