I am trying to find a certain string with RegEx.
I want to find "something starting with 'f' and ending with first 2" (it must contain only one 2). In this example I want to find result = "fdba12"
but the code at below is giving me 'fdba12312'
(containing two 2). How can I stop searching when I find 2 immediately?
import re
string2 = "asfdba12312 sssdr1 12şljş1 kf"
t = re.findall(r'[f][\w]*[2]', string2 )
print(t)