ts: ts: how to parse embedded commas 
Author Message
 ts: ts: how to parse embedded commas


| >    $x= "var1,var2, sum(sum(i,j), sum(k, sum(l, m))) as var3";
|
| you should be able to do something like:
|
| while($x =~ s/sum\(([^()]*)\)/&sum($1)/e) {}
|
| sub sum
|  {
|    my ($v1, $v2) = split(/\s*,\s*/, $_[0]);
|    return $v1 + $v2;
|  }
Thanks for the info. Unfortunately there *are* other functions
besides "sum", possibly hundreds of them. I know I could change
the regex to \w+ but I decided to use an array reference instead (1 var per element). --ts

  --------------------------------------------------------------------
  Posted using Reference.COM                   http://www.*-*-*.com/
  FREE Usenet and Mailing list archive, directory and clipping service
  --------------------------------------------------------------------



Sat, 12 Aug 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ts: how to parse embedded commas

2. ts: ts: Remove files in a PERL sript

3. ts: multiple keys for same value?

4. ts: double vs single quotes

5. ts: Remove files in a PERL sript

6. split on comma except when embedded inside quotes

7. Embedded new lines in a comma delimited file

8. Easy way to find Embedded Commas, etc?

9. reular expressions with embedded commas

10. Anybody using VMS Perl? Need short do's and don'ts

11. ts: why have "push" and "unshift"?

12. ts: unexpected behavior of "last" with "print"

 

 
Powered by phpBB® Forum Software