This may be a simple question, but I cannot get the result I want!
I have text similar to below:
text = 'To get to the destination follow this direction 1. First turn left and then text text text 2. Secondly you have to some text here some text here For the second instruction follow the text below: «1. some text some text some text text text text. 2. some text some text text text text. 3. some text some text text text text.»'
I am using regex in python and I want to get all the numbers between these "" "" "characters that are 1. 2. and 3.
I tried something like this:
test = re.findall(r'[«.*?](\d+)[.*?»]', text, re.DOTALL)
or that:
patt = re.findall(r'«.*?(\d+).*?»', text, re.DOTALL)
and many others, but not one of them returns what I want. What am I doing wrong?
Both patterns simply return number 1 without any other digit. What about numbers 2 and 3?
python regex
bettas
source share