Skip to content

Instantly share code, notes, and snippets.

@curiousstranger
Created March 21, 2010 01:17
Show Gist options
  • Save curiousstranger/339011 to your computer and use it in GitHub Desktop.
Save curiousstranger/339011 to your computer and use it in GitHub Desktop.
Search for a pattern in a file with python
# Open file
f = open('test.txt', 'r')
# Feed the file text into findall(); it returns a list of all the found strings
strings = re.findall(r'some pattern', f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment