in reply to Regexp match start or end

Adjust the good/bad sets as required.

use strict; use warnings; use Test::More; my @good = ( 'perfect weather', 'Nobody\'s Perfect', 'PeRfEcT!!', ); my @bad = ( 'imperfect', 'Perfecto!', 'perfection', ); my $re = qr/^perfect\b|\bperfect$/i; plan tests => @good + @bad; like $_, $re, "match for '$_'" for @good; unlike $_, $re, "no match for '$_'" for @bad;

🦛

Replies are listed 'Best First'.
Re^2: Regexp match start or end
by stevieb (Canon) on Jun 04, 2024 at 08:30 UTC

    ++

    Muy bien. Using \b as delimiters will eliminate most rogue issues such as:

    No es perfecto. Esto es imperfecto.

    More kudos for promoting testing utilities.