Help!
I'm trying to create a regex and I can't quite seem to get it right...
I'm trying to get several arguments out of a string which looks like:
args=['arg #1']
or
args=['arg #1', 'arg #2', 'arg #3']
I'd like to be able access the arguments via something like:
for(int i=1; i <= m.groupCount(); i++)
arg[i] = m.group(i);
The closest pattern I've gotten is:
"args=\\[(?:\'(.*?)\',)*\\s*\'(.+)\'\\]"
My problem is that for a single argument, I get arg[1] = null and
arg[2] = "arg #1" and for 3 or more arguments i get arg[1] = arg #1 and
arg[2] = arg #2' , 'arg #3 so it has something to do with it greedily
grabbing the rest of the characters.
Any ideas???
Thanks in advance!
Brian
Roedy Green - 07 Jan 2006 20:11 GMT
>My problem is that for a single argument, I get arg[1] = null and
>arg[2] = "arg #1" and for 3 or more arguments i get arg[1] = arg #1 and
>arg[2] = arg #2' , 'arg #3 so it has something to do with it greedily
>grabbing the rest of the characters.
>
>Any ideas???
tackle it as multiple problems.
find an arglist. Once you have that find the args, One you have that
process each arg.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.