Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8326

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

References <c4486911-f2cb-4e0e-a93c-3d6ff7e302e9@16g2000yqy.googlegroups.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2011-06-23 14:47 -0600
Subject Re: How do you print a string after it's been searched for an RE?
Newsgroups comp.lang.python
Message-ID <mailman.340.1308862058.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jun 23, 2011 at 1:58 PM, John Salerno <johnjsal@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How do you print a string after it's been searched for an RE? John Salerno <johnjsal@gmail.com> - 2011-06-23 12:58 -0700
  Re: How do you print a string after it's been searched for an RE? Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-23 14:47 -0600
    Re: How do you print a string after it's been searched for an RE? John Salerno <johnjsal@gmail.com> - 2011-06-23 14:14 -0700
  Re: How do you print a string after it's been searched for an  RE? "Thomas L. Shinnick" <tshinnic@prismnet.com> - 2011-06-23 16:47 -0500
    Re: How do you print a string after it's been searched for an RE? John Salerno <johnjsal@gmail.com> - 2011-06-23 15:02 -0700

csiph-web