Is Perl *that* good?

Wallclimber wallclimber21 at hotmail.com
Wed Apr 28 10:47:18 EDT 2004


Peter Otten <__peter__ at web.de> wrote in message news:<c6nks0$l3i$02$1 at news.t-online.com>...
> Wallclimber wrote:
> 
> Your example suggests that the Python equivalent for $1 is \1:
> 
> >>> re.sub(r"(\w+)\s*=\s*(\d+)", r"\2 <= \1", "a=1 b = 3 c = d")
> '1 <= a 3 <= b c = d'

I feel very stupid now. I've switched from Perl to Python about 3
years ago and always *dreaded* the used of regexen. I basically relied
on the online help to learn to use it and became convinced that I
*had* to use group.

Well, I've learned something now then. Thanks a lot!

Tom Verbeure



More information about the Python-list mailing list