How do i get values which has M at the end using Regex.
For example
some_str = '/dev/root 298.0M 210.9M 67.3M 76% /'
From above string i want to exact 298.0M , 210.9M and 67.M using Python Regex.
How do i get values which has M at the end using Regex.
For example
some_str = '/dev/root 298.0M 210.9M 67.3M 76% /'
From above string i want to exact 298.0M , 210.9M and 67.M using Python Regex.
import re
pat = '([0-9]+.[0-9]+[M])'
re.findall(pat, "/dev/root 298.0M 210.9M 67.3M 76% /")
Output:
['298.0M', '210.9M', '67.3M']