+---------------------------- start of character class
| +--------------- END of character class !!!
| |
| |+-------------- characters and metacharacters
| || from here on
| ||
| || +-------- START-OF-STRING anchor !!!
| || |
| || | +------ 0-or-more quantifier
| || | |
| || | |++---- empty capture group
| || | |||
| || | |||+--- literal ] character
| || | ||||
v vv v vvvv
m/[#@':;><,.{}[]=!"£$%^&*()]/
^ ^
| |
| +--- interpolated scalar $%
|
+------------------- interpolated array @'
####
Win8 Strawberry 5.8.9.5 (32) Sat 12/18/2021 23:35:28
C:\@Work\Perl\monks
>perl
use strict;
use warnings;
use Data::Dump qw(dd);
my $regex = qr/[#@':;><,.{}[]=!"£$%^&*()]/; # as posted pm#11139686
Possible unintended interpolation of @' in string at - line 7.
# my $regex = qr/[#\@':;><,.{}[\]=!"£\$%^&*()]/; # corrected
dd $regex;
no warnings 'qw';
for my $c (qw/ # @ ' : ; > < , . { } [ ] = ! " £ $ % ^ & * ( ) /) {
print "'$c' ", $c =~ $regex ? ' ' : 'NO', " match \n";
}
^Z
qr/[#:;><,.{}[]=!"£0^&*()]/
'#' NO match
'@' NO match
''' NO match
':' NO match
';' NO match
'>' NO match
'<' NO match
',' NO match
'.' NO match
'{' NO match
'}' NO match
'[' NO match
']' NO match
'=' NO match
'!' NO match
'"' NO match
'£' NO match
'$' NO match
'%' NO match
'^' NO match
'&' NO match
'*' NO match
'(' NO match
')' NO match
##
##
Win8 Strawberry 5.8.9.5 (32) Sat 12/18/2021 23:36:37
C:\@Work\Perl\monks
>perl
use strict;
use warnings;
use Data::Dump qw(dd);
# my $regex = qr/[#@':;><,.{}[]=!"£$%^&*()]/; # as posted pm#11139686
my $regex = qr/[#\@':;><,.{}[\]=!"£\$%^&*()]/; # corrected
dd $regex;
no warnings 'qw';
for my $c (qw/ # @ ' : ; > < , . { } [ ] = ! " £ $ % ^ & * ( ) /) {
print "'$c' ", $c =~ $regex ? ' ' : 'NO', " match \n";
}
^Z
qr/[#\@':;><,.{}[\]=!"£\$%^&*()]/
'#' match
'@' match
''' match
':' match
';' match
'>' match
'<' match
',' match
'.' match
'{' match
'}' match
'[' match
']' match
'=' match
'!' match
'"' match
'£' match
'$' match
'%' match
'^' match
'&' match
'*' match
'(' match
')' match
##
##
Win8 Strawberry 5.8.9.5 (32) Mon 12/20/2021 17:08:37
C:\@Work\Perl\monks
>perl
use strict;
use warnings;
no warnings 'qw';
for my $c (qw/
# @ ' : ; > < , . { } [ ] = ! " £ $ % ^ & * ( ) 1.2
0 1 2 - + -1 +1 12 +12 -12
/) {
my $is_blacklisted = $c =~ tr/#@':;><,.{}[]=!"£$%^&*()//;
print "'$c'", $is_blacklisted ? '' : ' NOT', " blacklisted \n";
}
^Z
'#' blacklisted
'@' blacklisted
''' blacklisted
':' blacklisted
';' blacklisted
'>' blacklisted
'<' blacklisted
',' blacklisted
'.' blacklisted
'{' blacklisted
'}' blacklisted
'[' blacklisted
']' blacklisted
'=' blacklisted
'!' blacklisted
'"' blacklisted
'£' blacklisted
'$' blacklisted
'%' blacklisted
'^' blacklisted
'&' blacklisted
'*' blacklisted
'(' blacklisted
')' blacklisted
'1.2' blacklisted
'0' NOT blacklisted
'1' NOT blacklisted
'2' NOT blacklisted
'-' NOT blacklisted
'+' NOT blacklisted
'-1' NOT blacklisted
'+1' NOT blacklisted
'12' NOT blacklisted
'+12' NOT blacklisted
'-12' NOT blacklisted