T
TonyV
Hey all, I've been trying to hammer away at this, and I just can't
figure it out. I'm hoping a regular expressions guru can help me out.
I'm trying to parse a retrieved javascript file to extract the
parameters out of a function call. Here's a contrived line that
represents what will be fetched:
foo('parameter 1', 'param with \'single\' quotes', 'param with\"double
\" quotes', 'this param, it has a comma', 'five');
The goal is to get an array with these elements:
parameter 1
param with 'single' quotes
param with "double" quotes
this param, it has a comma
five
There will always be five parameters, and the function name will
always be foo. Normally, I'm handy with regexes, but damn, those
escaped quotes and commas are killing me, and the data does have lots
of them in there.
I'm not lazy, I've been plugging away at this trying to work with look-
behind reference, greedy matching, and so on, but I'm just at an
impasse and can't extract what I want out of it. I've googled various
regex cookbooks (even have access to O'Reilly's Safari), but I've come
up with bupkiss.
Any ideas? I'd surely appreciate any help!
--TonyV
figure it out. I'm hoping a regular expressions guru can help me out.
I'm trying to parse a retrieved javascript file to extract the
parameters out of a function call. Here's a contrived line that
represents what will be fetched:
foo('parameter 1', 'param with \'single\' quotes', 'param with\"double
\" quotes', 'this param, it has a comma', 'five');
The goal is to get an array with these elements:
parameter 1
param with 'single' quotes
param with "double" quotes
this param, it has a comma
five
There will always be five parameters, and the function name will
always be foo. Normally, I'm handy with regexes, but damn, those
escaped quotes and commas are killing me, and the data does have lots
of them in there.
I'm not lazy, I've been plugging away at this trying to work with look-
behind reference, greedy matching, and so on, but I'm just at an
impasse and can't extract what I want out of it. I've googled various
regex cookbooks (even have access to O'Reilly's Safari), but I've come
up with bupkiss.
Any ideas? I'd surely appreciate any help!
--TonyV