Skip to content

Instantly share code, notes, and snippets.

@samduy
Created December 31, 2017 12:48
Show Gist options
  • Save samduy/f290dcf15791d62d86b419354ab32d0d to your computer and use it in GitHub Desktop.
Save samduy/f290dcf15791d62d86b419354ab32d0d to your computer and use it in GitHub Desktop.
Read all files in folder and search for regex
import glob, re
for msg in glob.glob('/tmp/*.txt'):
filer = open((msg),'r')
data = filer.read()
message = re.findall(r'<message>(.*?)>/message>', data, re.DOTALL)
print "File %s contains %s" % (str(msg), message)
filer.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment