python - Extracting from File using Regular Expression -


i have text document extract phrases from. phrase "mmarc5_" followed 4 numbers. have far:

with open("file.txt") f:     re = (mmarc5_)     re.findall(mmarc5_\d{4}", f.read()) 

i keep getting error:

nameerror: name 'mmarc5' not defined. 

you forgot quotes:

re.findall(r"mmarc5_\d{4}", f.read()) 

and line doesn't make sense, delete it:

re = (mmarc5_) 

did import re module?

import re 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -