I'm just beginning to learn regex, and am wondering how to get user input that can be used as a regex. Of course my attempt below doesn't work, but how should I modify it?

I'm practicing with phone.txt, which is 513 lines, each line having a name and phone number, and some other details like an address and times.

Sorry for the dumb question.

import re
s = raw_input("regex: ")
digs = re.compile(r"s")
for line in open("data//phone.txt"):
    if digs.search(line):
        print line

Thanks,

Dick Moores
[EMAIL PROTECTED]

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to