Regex help

Andy Armstrong andy at hexten.net
Fri Apr 20 16:41:58 BST 2012


On 20 Apr 2012, at 16:29, Simon Wistow wrote:
>    ^
>    (?::(\w+)      \s+)? # optional label
>    ([A-Za-z]+)    \s+   # opcode
>    ([^,\s]+) (?:, \s+   # operand
>    ([^,\s]+))*    \s*   # optional second opcode

You don't get a distinct capture for each application of the pattern - so the third operand overwrites the second. Maybe put the * inside the parens and then parse the list of operands in a second step?

-- 
Andy Armstrong, Hexten






More information about the london.pm mailing list