in reply to Re^2: combining lists along with a regex
in thread combining lists along with a regex
I think it adds legibility to make it a different step
I totally agree, in the general case. In this specific case, however, the first substitution — explicitly stripping off trailing whitespace — is in fact not needed at all, because the second substitution does that anyway:
18:14 >perl -wE "my $s = '2. Kim Washington '; $s =~ s/^\d+\.\s+( +\w+\s+\w).*$/$1. /; say qq['$s'];" 'Kim W. ' 18:14 >
Note also that in a substitution, only the left-hand part is a regex; the right-hand part is just an (interpolated) string, so the . doesn’t need to be escaped.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: combining lists along with a regex
by Aldebaran (Curate) on May 10, 2015 at 01:37 UTC | |
by Athanasius (Archbishop) on May 10, 2015 at 02:54 UTC |