diff options
| author | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-06-01 13:29:26 +0100 |
|---|---|---|
| committer | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-06-01 13:29:26 +0100 |
| commit | ea20ed349a9ef101246e58ad227e44ab9e4716e9 (patch) | |
| tree | 9e62ecc71b0cf58dc0ba4d1327daed402670ac0c | |
| parent | 8154af13c7c23a57d03c30e5387288b3da0ba4a6 (diff) | |
| download | perlweeklychallenge-club-ea20ed349a9ef101246e58ad227e44ab9e4716e9.tar.gz perlweeklychallenge-club-ea20ed349a9ef101246e58ad227e44ab9e4716e9.tar.bz2 perlweeklychallenge-club-ea20ed349a9ef101246e58ad227e44ab9e4716e9.zip | |
Last words
| -rw-r--r-- | challenge-063/simon-proctor/raku/ch-1.raku | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-063/simon-proctor/raku/ch-1.raku b/challenge-063/simon-proctor/raku/ch-1.raku new file mode 100644 index 0000000000..dd557ba8d8 --- /dev/null +++ b/challenge-063/simon-proctor/raku/ch-1.raku @@ -0,0 +1,13 @@ +#!/usr/bin/env raku + +use v6.d; + +sub last_word( Str $sentence, Regex $test ) { + $sentence.words.reverse.first( $test ); +} + +# Test Last_word +say last_word(' hello world', rx/<[ea]>l/); # 'hello' +say last_word("Don't match too much, Chet!", rx:i/ch.t/); # 'Chet!' +say last_word("spaces in regexp won't match", rx/"in" " " "re"/); # undef +say last_word( join(' ', 1..1e6), rx/^(3.*?) ** 3/); # '399933' |
