in reply to Parse TCL list?

Hi.

Yes, that's it. Im not 100% sure if the second line is even possible....

Is there a way to do "or" for strings like those examples? What I mean is if the list is like the first one, there is no '{' at all (so its easy to split by \s), but the second one should return 'eka', 'toka soka' and 'kolo'. The third one works okay with your example.

Replies are listed 'Best First'.
Re: Re: Parse TCL list?
by tilly (Archbishop) on Nov 08, 2003 at 16:02 UTC
    In regular expressions, the | symbol means "or".
    #! /usr/bin/perl use strict; use Regexp::Common; my $string = "@ARGV"; print "$_\n" for $string =~ /(\w+|$RE{balanced}{-parens=>'{}'})/g;
    That seems to produce correct output for all of your examples.