"...but not 'CHECK_ABC123_A1.txt' "
Nope! Not true.
C:\>perl -E "my $s='CHECK_ABC123_A1.txt';say $s if ($s =~ m/^CHECK_(\w
++)\.txt/ );"
CHECK_ABC123_A1.txt
or, alternately,
#!/usr/bin/perl
use 5.016;
use strict;
use warnings;
# 1042260
my $s='CHECK_ABC123_A1.txt';
if ( $s =~ m/^CHECK_(\w+)\.txt/ ) {
say "\t \$1 is: $1\n\t and the regex matched the source string.";
} else {
say "\t Nope. Regex didn't match \$s.";
}
=head OUTPUT:
$1 is: ABC123_A1
and the regex matched the source string.
=cut
Pls test your advice... (unless you were trying to get a clueless OP to turn in homework with an error).
If you didn't program your executable by toggling in binary, it wasn't really programming!
|