How do you print a string after it's been searched for an RE?

Ian Kelly ian.g.kelly at gmail.com
Thu Jun 23 16:47:07 EDT 2011


On Thu, Jun 23, 2011 at 1:58 PM, John Salerno <johnjsal at gmail.com> wrote:
> After I've run the re.search function on a string and no match was
> found, how can I access that string? When I try to print it directly,
> it's an empty string, I assume because it has been "consumed." How do
> I prevent this?

This has nothing to do with regular expressions. It would appear that
page.read() is letting you read the response body multiple times in
2.x but not in 3.x, probably due to a change in buffering.  Just store
the string in a variable and avoid calling page.read() multiple times.



More information about the Python-list mailing list