Hey,
I am trying to do a regular expression but I am running into a problem because the scalar that I am doing the test on may or may not have regular expression syntax in it. When it has regular expression syntax in it...it doesn't work...confused? Maybe an example will explain it better than me
I think it is the | in the value that is causing the problem (I could be wrong). How can I get the regular expression to ignore any of this syntax in the scalar?
Thanks for the help.
Later
I am trying to do a regular expression but I am running into a problem because the scalar that I am doing the test on may or may not have regular expression syntax in it. When it has regular expression syntax in it...it doesn't work...confused? Maybe an example will explain it better than me
Code:
#options is an array that contains select box options:
my @options = ("<option value=\"apg_status iLIKE 'Active' OR apg_status = '2004'&Active|2004\">2004</option>",
"<option value=\"apg_status iLIKE 'Active' OR apg_status = '2005'&Active|2005\">2005</option>",
"<option value=\"apg_status iLIKE 'Active' OR apg_status = '2006'&Active|2006\">2006</option>",
"<option value=\"apg_status iLIKE 'Active' OR apg_status = '2006'&Active\">2006</option>"
);
#as you can see some of the options have &Active|2006 at the
#end...it is these ones that are causing the problem
#status is what I am testing for:
#this doesn't work
my $status = "apg_status iLIKE 'Active' OR apg_status = '2006'&Active|2006";
#this does work
#my $status = "apg_status iLIKE 'Active' OR apg_status = '2006'&Active";
map{$_=~s/<option value=(["']$status['"])>/<option value=$1 selected>/gi}@options;
print("@options\n");
I think it is the | in the value that is causing the problem (I could be wrong). How can I get the regular expression to ignore any of this syntax in the scalar?
Thanks for the help.
Later