Newbie: searching an English dictionary for a reg exp

^^@++ ballsacks at xtra.co.enzed
Wed Dec 5 06:22:02 CET 2001


On Mon, 3 Dec 2001 20:57:58 -0800, "Eugene" <import binascii; print
binascii.a2b_base64('ZXVnZW5lQGlzb21lZGlhLmNvbQ==')> wrote:

>Oh, sorry about that.  "re.search" only requires that the pattern match at
>the start of the target string; it does not also require that the pattern
>match all the way to the end.  Put "$" at the end of your pattern and that
>will fix it.  (The regular expression "$" means end-of-string.*)

Thanks, I didn't know I needed the $.

>And if you just want to print the word that matched, just put
>"outfile.write( word + ' ' )" in place of what you have in your "if" block.
>Once you know the word matches, that's good enough for you, right? :)

Duh, how'd I miss that. Thanks again. Problem solved!

-Matt



More information about the Python-list mailing list