Regex help

Anthony Lucas anthonyjlucas at gmail.com
Fri Apr 20 21:37:42 BST 2012


How about a parser using Regexp? Parser::MGC?

You can implement a proper parser, or just a few staged regexp, or anything in-between.


-----Original Message-----
From: Dave Hodgkinson <davehodg at gmail.com>
Sender: london.pm-bounces at london.pm.org
Date: Fri, 20 Apr 2012 17:15:29 
To: London.pm Perl M\[ou\]ngers<london.pm at london.pm.org>
Reply-To: "London.pm Perl M\[ou\]ngers" <london.pm at london.pm.org>
Subject: Re: Regex help

Or use a proper parser?

On 20 Apr 2012, at 16:41, Andy Armstrong wrote:

> 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