Quote (carteblanche @ Apr 23 2015 06:39pm)
it's totally understandable that you wouldn't have thought of the idea, but after i introduce you to the idea, it's up to you to research it. whether or not you know python doesn't matter much.
http://lmgtfy.com/?q=python%20read%20file%20into%20stringnow spend some time trying it, then post here with code if you're still running into problems.
Looked through everything I could find, actually Googled something similar. Most, if not all, had the file names hard-coded.
Code
import re
fileName = input('Please enter the name of the file containing the input zicpcodes: ')
fileObject = open(fileName, 'r')
string = fileObject.read()
for eachLine in fileObject:
string = string
pattern = '^([0-9]{5}|[0-9]{9})$'
m = re.match(pattern, string)
if m is not None:
print("Match found with: ", string, "\n")
else:
print("Error - no match with: ", string, "\n")
fileObject.close()
I ran it and it didn't stop running. Anything stick out about this? I figured string = string is wrong, but I don't know what to replace the value with.