#!/usr/bin/env perl use utf8; use English; use Utils; use strict; use warnings; MAIN: { binmode(STDOUT, ":utf8"); binmode(STDERR, ":utf8"); binmode(STDIN, ":utf8"); my $s = "Four score and seven years ago..."; print "Match 1: ", $s =~ qr/s.*e/, "\n"; print "Match 2: ", $s =~ qr/\bs.*e\b/, "\n"; print "Match 3: ", $s =~ qr/s...e/, "\n"; print "Match 4: ", $s =~ qr/b.d/, "\n"; my $subgroups = [$s =~ qr/((\w+)\s*(\w+))/]; print "Find First (with subgroups): ", Utils::listToString($subgroups), "\n"; $subgroups = [$s =~ qr/bad match/]; print "Find First (bad match): ", Utils::listToString($subgroups), "\n"; my $matches = [$s =~ m/\w+/g]; print "Find All: (matches only)", Utils::listToString($matches), "\n"; $matches = [$s =~ m/bad match/g]; print "Find All (bad match): ", Utils::listToString($matches), "\n"; }