Trouble with regexes

Tim Roberts timr at probo.com
Fri May 27 00:08:27 EDT 2005


Fernando Rodriguez <frr at THOU_SHALL_NOT_SPAMeasyjob.net> wrote:
>
>I'm trying to write a regex that matches a \r char if and only if it
>is not followed by a \n (I want to translate text files from unix
>newlines to windows\dos).
>
>I tried this, but it doesn't work:
>p = re.compile(r'(\r)[^\n]', re.IGNORECASE)
>
>it still matches a string such as r'\r\n'

Hint: the string r'\r\n' contains four characters.  It contains neither
carriage return nor newline.

Bigger hint: the string '\r\n' contains two characters.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list