Recently I stumbled upon a problem that can be solved with Perl like so:
$line = " highlight! tag guifg=#000000 guibg=#111111 gui=#2222222 guisp=#333333 # COMMENT"
for $tok ($line =~ m/(?>^ *highlight!? +\w+)|\G(?> +gui(?:bg|fg|sp)?=#\d+)|(?> +#.*$)/g)
{
print "[[$tok]]\n";
}
The output - correctly - consists of all defining parts of the highlighting definition. However - naively - implementing this in Nim like this:
import nre
import options
let line = r" highlight! tag guifg=#000000 guibg=#111111 gui=#2222222 guisp=#333333 # COMMENT";
let highlight = re(r"(?>^ *highlight!? +\w+)|\G(?> +gui(?:bg|fg|sp)?=#\d+)|(?> +#.*$)")
for tok in line.match(highlight).get.captures.toSeq():
echo "[[", tok, "]]"
gives me no output. What am I doing wrong? Is this (here, using "G") possible in Nim?