i usually avoid regex unless absolutely required. Here it is not because you can parse the string through process of elimination. And based on the fact that your regex string contains this in every file.
s = '''"SYS"."M_SYSTEM_OVERVIEW" ('System', 'Version', '', '2.00.050.00.1592305219 (fa/hana2sp05)')''' version = s.split(',')[3].split(' ')[1].strip("'") print(version)outputs from elimination to final desired output. From why each index was selected from a certain split character
Output:metulburr@metulburr:~$ python3 test2.py
['"SYS"."M_SYSTEM_OVERVIEW" (\'System\'', " 'Version'", " ''", " '2.00.050.00.1592305219 (fa/hana2sp05)')"]
metulburr@metulburr:~$ python3 test2.py
'2.00.050.00.1592305219 (fa/hana2sp05)')
metulburr@metulburr:~$ python3 test2.py
['', "'2.00.050.00.1592305219", "(fa/hana2sp05)')"]
metulburr@metulburr:~$ python3 test2.py
'2.00.050.00.1592305219
metulburr@metulburr:~$ python3 test2.py
2.00.050.00.1592305219
The only thing that has to be added is obtaining the original string section from the file which could be different based on what the content of the file contains. You would have to find something unique in that string in comparison to parse out the rest of the file. Or for example if it has 1000 commas in the file, the index could be 98 instead of 3, etc.
Recommended Tutorials: