I have the following content:
[QUOTE]----------
ID: php_install
Function: pkg.installed
Name: php
Result: True
Comment: All specified packages are already installed
Started: 16:19:04.217642
Duration: 587.977 ms
Changes:
----------
ID: mod_mysql
Function: pkg.installed
Name: php-mysql
Result: True
Comment: All specified packages are already installed
Started: 16:19:04.805807
Duration: 14.708 ms
Changes:
----------/QUOTE]
In this course I'm watching, I have the following example, which works as expected:
Code:
grep -Po '(ID|(?<fn>Function)|(?<dur>Duration)): (?(fn)\w+?\.\w+|(?(dur)\d+\.\d+ ms|\w+))' high20.txt
ID: php_install
Function: pkg.installed
Duration: 587.977 ms
ID: mod_mysql
Function: pkg.installed
Duration: 14.708 ms
But whenever I try this:
Code:
grep -Po '(ID|(?<fn>Function)|(?<comm>Comment)): (?(fn)\w+?\.\w+|(?(comm)\w+?\s\w+)|\w+))' high20.txt
I get the following error:
Code:
grep: conditional group contains more than two branches
Which really intrigues me, because the only significant difference I can see is the naming convention that I attribute to the regex ("comm" instead of "dur" and the regex itself which is only slightly difference, but I'd say there shouldn't make any difference to the syntax itself). Any ideas what's going on?
Never mind - an additional unnecessary paranthesis. Only after I posted it did I see it. I couldn't perceive it as such in the command line.
So instead of \s\w+)| it should have been \s\w+|