Re: [Tutor] A simple Perl to Python regex xlation question

2005-04-22 Thread Gavin Henry
On Wednesday 20 Apr 2005 20:07, Kent Johnson wrote: > Smith, Jeff wrote: > > What's the quickest (and most Pythonic) way to do the following Perlism: > > $str = s/d+/d/; > > > > (i.e. collapsing multiple occurrences of the letter 'd' to just one) > > import re > s = re.sub('d+', 'd', s, 1) > >

Re: [Tutor] A simple Perl to Python regex xlation question

2005-04-20 Thread Kent Johnson
Smith, Jeff wrote: What's the quickest (and most Pythonic) way to do the following Perlism: $str = s/d+/d/; (i.e. collapsing multiple occurrences of the letter 'd' to just one) import re s = re.sub('d+', 'd', s, 1) if I understand the perl...this replaces just one occurance of d+. If you wa

[Tutor] A simple Perl to Python regex xlation question

2005-04-20 Thread Smith, Jeff
What's the quickest (and most Pythonic) way to do the following Perlism: $str = s/d+/d/; (i.e. collapsing multiple occurrences of the letter 'd' to just one) Thanks, Jeff ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/lis