John W. Krahn wrote at Sun, 14 Jul 2002 13:45:19 +0200:

> my @tokens = split /({\\[^\s}{]+|\\[^\s\\}]+|\\[\\}]|})/, $line;
>                       ^^         ^^          ^^   
 
Perhaps we can simplify even this regex:

my @tokens = split / ( \\ (?: [^\s{}]+  |
                              [^\s\\}]+ |
                              [\\}]       )
                       | }
                     )/x
             => $line;

[untested]

To increase speed, we can make also a lookahead statement:

my @tokens = split / ( \\ (?=\S)            # there's never a whitespace
                          (?: [^\s{}]+  |
                              [^\s\\}]+ |
                              [\\}]       )
                       | }
                     )/x
             => $line;

Best Wishes,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to