2021年4月27日星期二

Parsing a text file with regex

For example, I have a sample text file as displayed below that I need to fetch information from:

Sider_DLL: version 6.3.9 (0)  Filename_match: PES2020.exe  handle1 = 40923  debug = 0  game_priority_class = 0x0  livecpk_enabled = 1  lookup_cache_enabled = 1  lua_enabled = 1  lua_gc_opt = step  jit_enabled = 1  luajit_ext_enabled = 1  dummify_uniparam = 1  key-cache_ttl_sec = 10  rewrite-cache.ttl-sec = 10  cache.size = 32  

I am wondering if I can use regex in order to get the data in lines 1,2,9, and 13 and output a concatenated string: "version 6.3.9(0)PES2020.exestep10". I have the following line and does not return the right output.

re.findall(r'Sider_DLL:: (\\w\w\w\w\w\w\w\s\d+)[ a-zA-Z]+Filename_match:(a-z)+[ a-zA-Z]+lua_gc_opt= (a-zA-Z))   
https://stackoverflow.com/questions/67293239/parsing-a-text-file-with-regex April 28, 2021 at 11:12AM

没有评论:

发表评论