Perl Challenge: Fun with Character Classes
Perl Challenge: What characters do the following regex character
classes include?
[--^]
[^-^]
[-^]
[^--^]
[^-]
[^^]
Answers tomorrow!
Perl Challenge: What characters do the following regex character
classes include?
[--^]
[^-^]
[-^]
[^--^]
[^-]
[^^]
Answers tomorrow!
My real name is Jeremy Holland. I've been a programmer for 25 years, using primarily Perl since 2000.
Where are my answers?!
1. dash thru caret
to check:2. neither dash nor caret
3. dash or caret
4. opposite of 1
5. no dash
6. no caret
use 5.012; # implies strict + feature 'say' use Data::Dumper; my %matches; for my $cc (qw/--^ ^-^ -^ ^--^ ^- ^^/) { my $re = qr/[$cc]/; my $match = ''; do {$match .= chr($_) if chr($_) =~ $re} for (32..126); # printable ascii $matches{$cc} = $match; } say Dumper \%matchesCorrect! You win a hearty handshake if I ever meet you in person!
Toby, I was waiting to see if anyone would submit guesses!