Clinton writes ..

>I'm tring to extract some values delimited by quotes
>I can extract the first set using "([^"]*) but not the second set using
>"([^"]*),"([^"]*). Could I have a clue please?

a) you're forgetting the closing quote

  /"([^"]*)","([^"]*)"/

b) the while(<STUFF>) processes one line at a time .. and so assuming that
your TEST.TXT is split over a number of lines as you have shown it below -
even the first match shouldn't work

but I suspect that your data representation below is not accurate .. in
which case you really need to provide it accurately for this sort of
question


>CODE
>use strict;
>my $file = "test.txt";
>
>#extract from file
>my $stuff="e:/$file";
>open STUFF, $stuff or die "Cannot open $stuff for read :$!";
>
>while (<STUFF>) {
>if (/new Array\\\(\\\);\\nkeyComp\[.+\] = "([^"]*)/g){
>print "$1 \n";
>
>}
>}
>print "END OF FILE";

you should probably slurp the whole file into one scalar to do the regex on
.. so after the open you'd have something like this

  my $file_contents = do { local $/; <STUFF> };

then you'd process $file_contents something like this

  $file_contents =~ /"([^"]*)","([^"]*)"/;
  print "[$1] [$2]\n";

-- 
  jason king

  You must pay a fine of $600 in Thailand if you're caught throwing
  away chewed bubblegum on the sidewalk. If you do not pay the fine,
  you are jailed. - http://dumblaws.com/

Reply via email to