I want to extract the version numbers using python regular expression.
The below string is stored in "str1" variable
show.sh
{
"sys_0_num" : {
"rel_num": 2.3,
"version": 14891
},
"sys_1_num" : {
"rel_num": 2.3,
"version": 14891
}
"cha_num" : {
"rel_num": 2.3,
"version": 571,
"model":1487
}
}
I want to extract the version number from each component i.e.,
sys_0_num version: 14891
sys_1_num version: 14891
cha_num version": 571
I tried this below linecode, but unable to get the desired output (the above string is stored in str1
variable):
Sample code
output2 = re.findall(r'sys_0_num\[version]:\s*(\d+)',str1)[0]