regulare expression searches and newlines

Fredrik Lundh effbot at telia.com
Mon Apr 24 03:51:39 EDT 2000


schmitthead at my-deja.com wrote:
> I was doing a search like this:
>
> searchobj = re.compile( r'^foobarbaz' )
>
> where I was looking for something at the beginning of a line.  This
> works well for native text files, but not when I was searching through
> Linux files running on NT or NT files on Linux or some other variation
> because of the newline difference, I guess.  Is there any way to handle
> the general case?

there's nothing wrong with your regular expression.

I suggest printing the strings you're trying to match against,
to see if you can figure out what's wrong.

if that doesn't help, post the code.

</F>





More information about the Python-list mailing list