I´m currently facing the problem that I have a string of 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 it returned me two numbers but I only want to have the first one "27184".
Hence, I tried with the following code:
print (re.findall('/^[^\d]*(\d+)/', headline ))
But It does not work:
Output:[]
Can you guys help me out? Any feedback is appreciated
>>> re.search(r'\d+',Headline).group(0) '27184'print (re.findall(r'^[^\d]*(\d+)', headline ))findall, which finds all the occurrences. By the way, Python regular expressions do not require/characters.