[Tutor] redemo.py and r'python\.org'

Dick Moores rdm at rcblue.com
Fri Oct 14 04:04:31 CEST 2005


Kent Johnson wrote at 14:36 10/13/2005:
>Dick Moores wrote:
> > I've begun to try out redemo.py to test and learn regular 
> expressions. It
> > doesn't seem to accept Python's raw strings as raw strings, e.g.,
> > r'python\.org'  for matching  python.org  and nothing else. Am I 
> correct,
> > or is there something I don't understand here?
>
>In redemo you just type the actual regex string, no quotes or r prefix. 
>So if you type into the top text box
>   python\.org
>and in the middle text box
>   python.org
>then you will get a match.
>
>In your program then you have to type the regex as a string literal so 
>you would type
>   r'python\.org'
>
> > (A question about quoting in a Tutor post: in my 1st paragraph above, 
> how
> > could I have indicated that I am quoting both
> >
> > r'python\.org'   and     python.org
> >
> > without using quotation marks to do so, so as to not confuse the 
> regex? I
> > think I remember someone recently using angled brackets. So how about
> > <r'python\.org'> and <python.org>?  Is there a convention about this?)
>
>I found it clear the way you typed it. In my response I set the strings 
>off with newlines and an indent. Angle brackets would probably work fine 
>too. IOW I don't think there is really a convention.

If they're OK, I'll go with angle brackets unless they would be ambiguous.

BTW in redemo.py, what do the checkboxes VERBOSE, LOCALE, and DOTALL 
mean? (I understand IGNORECASE and MULTILINE.)

Thanks,

Dick



More information about the Tutor mailing list