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)
>
>
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
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