First I am using python 2.7
I have these possibilities of the string:
3 paths
12 paths
12 path rooms
Question
what is the reqular expression to get the number without the text.
(\d+).*\n for pulling the numbers and then skipping the rest of the line.
number_finder = re.compile('(\d+).*\n')
number_finder.findall(mystr)
will output an array of the number values
Example:
In [3]: r = re.compile('(\d+).*\n')
In [4]: r.findall('12 a \n 12 a \n')
Out[4]: ['12', '12']
re.M flag, it codes like re.findall(r'\d+',multiple_line_string,re.M) :-)The regex pattern to look for is \d. So in python you would code it as:
pattern = re.compile(r'\d+')
result = re.search(pattern, input_string)
[\d]* with the * so it will catch all the number and not just the first digit.\d+
stroperations