Search notes:

Perl function: qr

#!/usr/bin/perl
use warnings;
use strict;
use feature 'say';

my $pattern_contains_a_2_digit_number = qr/\b\d{2}\b/;

say $pattern_contains_a_2_digit_number;
# (?^:\b\d{2}\b)

say ref($pattern_contains_a_2_digit_number);
# Regexp

say '';

does_it_match("foo 4   bar"); # foo 4   bar does not match
does_it_match("foo 42  bar"); # foo 42  bar matches
does_it_match("foo 421 bar"); # foo 421 bar does not match


sub does_it_match { # {{{

    my $text = shift;

    if ($text =~ $pattern_contains_a_2_digit_number) {
      say "$text matches";
    }
    else {
      say "$text does not match";
    }
    
} # }}}
Github repository about-perl, path: /functions/qr.pl

See also

Perl functions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758207331, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/functions/qr(75): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78