in reply to Re: how to check whether a particular word exists in filename
in thread how to check whether a particular word exists in filename
"...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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to check whether a particular word exists in filename
by Happy-the-monk (Canon) on Jul 03, 2013 at 23:30 UTC |