Kozz has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (regular expressions)
If I were to create something like
It's awfully hard for the interpreter to know that TEST is actually a constant, because to the regex engine it's just another string. The /e modifier doesn't work. Is there a way to do this?use constant TEST => 'def'; my $string = 'abcdefg'; if ($string =~ /TEST/) { print "The string contains the constant.\n"; }else{ print "The string doesn't contain the constant.\n"; }
Originally posted as a Categorized Question.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using CODEconstant/CODEs in regexes?⭐
by japhy (Canon) on Aug 11, 2001 at 02:54 UTC | |
Re: Using CODEconstant/CODEs in regexes?
by abstracts (Hermit) on Aug 11, 2001 at 02:52 UTC | |
by japhy (Canon) on Aug 11, 2001 at 03:11 UTC | |
by abstracts (Hermit) on Aug 11, 2001 at 03:20 UTC | |
Re: Using constants in regexes?
by dclayton (Initiate) on Feb 01, 2005 at 20:13 UTC | |
by diotalevi (Canon) on Feb 01, 2005 at 20:48 UTC | |
Re: Using constants in regexes?
by freonpsandoz (Beadle) on Sep 08, 2015 at 09:23 UTC |
Back to
Seekers of Perl Wisdom