value=['0.203973Noerror(0)', '0.237207Noerror(0)','-1Timedout(-2)']
pattern=re.compile("\D\\(\d|[-]\d\\)")
temp=[]
for i in range(0,len(value)):
err=pattern.match(value[i])
if err:
temp=value[i]
print(temp)
I want parsing the value:
[Noerror(0),Noerror(0),Timedout(-2)]
But when I'm processing code, the result is:
[0.203973Noerror(0),0.237207Noerror(0)',-1Timedout(-2)]
I don't know why this result comes out... please advice to me.
matchtosearch, asmatchalways starts matching from the beginning of the string.re.search(r'[a-zA-Z]+\(-?[0-9]+\)$', value[i]).group()re.search(r'[^(0-9]+\([^)]+?\)',value[i]).group().