[Tutor] re question
Sat Apr 26 16:37:02 2003
On Sat, Apr 26, 2003 at 03:50:41PM -0400, Timothy M. Brauch wrote:
> I'm working with the re module, doing some file processing. I have a
> question that maybe someone can explain to me. The re module talks about
> raw strings and I'm not quite sure I understand what a raw string is and how
> it differs from a regular string. What is the difference?
A raw string doesn't translate escape sequences and such. Raw strings are
preceeded by an 'r'. Example:
>>> print 'Hello\n'
>>> print r'Hello\n'
In a raw string you can put special characters and likewise how you want
without them getting their special meaning, they are just characters. Or you
can see it so that Python automatically escapes the special characters so they
lose their special meaning.