in reply to Regular expression to match an A=B type string needs help in storing matched parts of string

I tried to test this and it seems as though your regular expression is working fine. I had to make some small changes to test it and removed the single quotes on the second line ('$gpa $gpa_key') and replaced it with ($gpa_ret = "gpa: $gpa_key"). Otherwise, the value would not interpolate for the regex.
my $gpa_key = "azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/R +TS/etc/local/azxfiles'"; my $gpa_ret = "gpa: $gpa_key"; warn $gpa_ret; print "gpakey: $gpa_key\n"; #print "gparet: $gpa_ret\n"; if ( $gpa_ret =~ /[^=]+[=][']([^']+)[']/ ) { my $assigned_dir = $1 ; print "$assigned_dir\n";} else { die "couldn't determine assigned directory for $gpa_key" + }
By making this change, we are now passing the string instead of the literal name of the variable. You were actually testing the regex conditions on `$gpa $gpa_key` instead of the string value. The output from my modified version is:
gpa: azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/RTS/etc/loc +al/azxfiles' at D:\DATA_TO_MIGRATE\dbexamples\ex\gpa.pl line 7 . gpakey: azxinetgw.EXECFILE_DIR.azxinetgw='/usr/local/instinet/RTS/etc/ +local/azxfiles' /usr/local/instinet/RTS/etc/local/azxfiles

Mick
  • Comment on Re: Regular expression to match an A=B type string needs help in storing matched parts of string
  • Select or Download Code