Currently, I am facing the problem that I have a string from which I want to extract only the first number. My first step was to extract the numbers from the string.
Headline = "redirectDetail('27184','2 -New-York-Explorer-Pass')" print (re.findall('\d+', headline )) Output is ['27184', '2']
In this case, he returned me two numbers, but I only want to have the first "27184".
Therefore, I tried to use the following code:
print (re.findall('/^[^\d]*(\d+)/', headline ))
But this does not work:
Output:[]
Can you guys help me? Any feedback is welcome
python string numbers
Serious ruffy
source share