in reply to Non-greedy substitution
Reusing choroba's tests.
#!/usr/bin/perl use warnings; use strict; use experimental qw( signatures ); sub non_oxford_list($s) { $s =~ s/,([^,]+)$/ and$1/r } use Test::More tests => 3; is non_oxford_list('A'), 'A'; is non_oxford_list('A, B'), 'A and B'; is non_oxford_list('A, B, C'), 'A, B and C';
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Non-greedy substitution
by LanX (Saint) on Nov 16, 2024 at 08:17 UTC |