rpike has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I have a regular expression in place that does a check on a string coming in from a form. The regular expression is as such :
$string =~ m/^(frm)(\w+)(txt)?$/;
What I was hoping to accomplish was to have $1, $2, and $3 populated with the values in the brackets. When I run this and the string is something like frmNametxt the $1 gets set to frm, $2 gets set to Nametxt and $3 to nothing. What (if anything) can I do to force the code to evaluate and store txt into $3? If txt is there I want it put into $3. Any help would be most appreciated. Thanks.
Rob
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: RegExp Matched Values
by jethro (Monsignor) on Apr 30, 2010 at 13:37 UTC | |
by AnomalousMonk (Archbishop) on Apr 30, 2010 at 14:43 UTC | |
Re: RegExp Matched Values
by AR (Friar) on Apr 30, 2010 at 13:30 UTC |
Back to
Seekers of Perl Wisdom