Kozz has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (regular expressions)
#!/usr/bin/perl my %hash=( 'a', '2', 'b', '5', 'a+b', '7', ); my $string='a+b'; my $key; foreach $key (keys %hash){ if($string=~/$key/){ print "I found a match: \"$key\"\n"; }else{ print "There was no match for \"$key\"\n"; } }
Originally posted as a Categorized Question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I escape meta-characters in a user-defined string?⭐
by btrott (Parson) on Mar 25, 2000 at 01:05 UTC |