Note: I'm sorry for the long disclaimer in these emails. I have put in requests to GMANE and Nabble to archive this list, so hopefully my future posts (while at $dayjob) will be easier for others to trim and reply to. With that said, I continue...
Ok, I'm wondering what would be the best way to test for a match against a grammar where there may be up to 25 "junk" characters preceding the match. We know that PRD does not do backtracking: http://search.cpan.org/dist/Parse-RecDescent-FAQ/FAQ.pm#Answer_by_Randal_L._Schwartz And we know that greediness is difficult to control: http://search.cpan.org/~dconway/Parse-RecDescent-v1.95.1/lib/Parse/RecDescent.pm#ON-GOING_ISSUES_AND_FUTURE_DIRECTIONS But given all that, and the toy grammar below, which matches "sir george", how could we modify it to match "io;ajwer;i324 sir george" One possible strategy is to simply feed 25 successive substrings, chopping off one character at a time. #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use lib '.' ; use Parse::RecDescent; { #last; #$::RD_WARN++; #$::RD_HINT++; $::RD_TRACE++; } $::RD_AUTOACTION = q { [EMAIL PROTECTED] } ; my $G = << 'EOGRAMMAR' ; name: name_types eofile { $return = $item[1] } eofile: /^\Z/ name_types: royal royal: title firstname of(?) title: 'sir' | 'his holiness' firstname: 'george' | 'john' of: 'of' place place: 'kent' EOGRAMMAR my $p = Parse::RecDescent->new($G) ; my $string = "sir george"; my $parser = 'name' ; my $r = $p -> $parser ( $string ) ; warn Dumper $r; -- Terrence Brannon - SID W049945 614-213-2475 (office) 614-213-3426 (fax) 818-359-0893 (cell) ----------------------------------------- This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities.