regex string matching python3

MRAB python at mrabarnett.plus.com
Mon Oct 1 15:14:59 EDT 2018


On 2018年10月01日 18:49, nanman3012 at gmail.com wrote:
> I have a string like this:
>> b'\tC:94.3%[S:89.9%,D:4.4%],F:1.7%,M:4.0%,n:1440\n'
>> And I would like to extract the numbers corresponding to S,D,F and M in this string and convert them into an array like this:
>> [ '89.9', '4.4', '1.7', '4.0']
>> Any help would be appreciated!
>Try this:
 re.findall(r'\b[SDFM]:(\d+\.\d+)', data.decode('ascii'))


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /