On Tue, Jan 4, 2011 at 11:57, Richard D. Moores <[email protected]> wrote:
> On Tue, Jan 4, 2011 at 10:41, Richard D. Moores <[email protected]> wrote:
>> Please see http://tutoree7.pastebin.com/z9YeSYRw . I'm actually
>> searching RTF files, not TXT files.
>>
>> I want to modify this script to handle searching on a word. So what,
>> for example, should line 71 be?
>
> OK, I think I've got it.
>
> in place of lines 66-75 I now have
>
> search = input("first search string: ")
> search = "\\b" + search + "\\b"
> if not search:
> print("Bye")
> sys.exit()
> elif search[0] != ' ':
> p = re.compile(search, re.I)
> else:
> p = re.compile(search)
Oops. That should be
search = input("first search string: ")
if not search:
print("Bye")
sys.exit()
elif search[0] != ' ':
search = "\\b" + search + "\\b"
p = re.compile(search, re.I)
else:
search = "\\b" + search + "\\b"
p = re.compile(search)
Dick
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor