On Dec 13, 9:00 pm, Davy <[EMAIL PROTECTED]> wrote:
>
> What's "\1" and the whole re.sub() mean?
>
Read about backreferences here:
http://www.regular-expressions.info/brackets.html
Also see the entry on parentheses here:
http://docs.python.org/lib/re-syntax.html
rick
--
http://mail.python.or
Hi all,
I have read a re.sub() that confused me.
s = 'P & Q'
s = re.sub(r'([a-zA-Z0-9_.]+)', r'Expr("\1")', s)
What's "\1" and the whole re.sub() mean?
Best regards,
Davy
--
http://mail.python.org/mailman/listinfo/python-list
Glad I could help.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks a lot! Compiling with re.DOTALL did fix my problem for the most
part; there still are a few problems with my code, but I think I can
fix those myself.
Again, thanks!
> Okay I just woke up and haven't had enough coffee so if I'm off here
> please forgive me. Are you saying that if there is
Okay I just woke up and haven't had enough coffee so if I'm off here
please forgive me. Are you saying that if there is an emptly line then
it borks? If so just use re.S ( re.DOTALL ) and that should take care
of it. It will treat the ( . ) special. Otherwise it ignores new
lines.
--
http://m
Actually, it happens in general when there is more than one linebreak
between the open and close statements; not only when there are empty
lines.
--
http://mail.python.org/mailman/listinfo/python-list
I'm trying to make a (tiny) template system (Cheetah and like have far
more than what I need), but I've run into a problem. To simplify
everything, I've decided to make for loops matching the indentation
level of the open and close statements; it appears to work fine, but
apparently it chokes once