Skip to content

Instantly share code, notes, and snippets.

@PietrH
Created July 5, 2019 12:12
Show Gist options
  • Save PietrH/04b5042462b20b823ac835a4c19562fb to your computer and use it in GitHub Desktop.
Save PietrH/04b5042462b20b823ac835a4c19562fb to your computer and use it in GitHub Desktop.
Extract a number from a string in Python using regular expressions
import re #regular expressions in Python
def number_from_string(string):
return re.findall("\d+",string)
#The function will return a list of all digit sequences in the string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment