On Fri, 12 Nov 2004, Christopher Hahn wrote: > I am trying to use Parse::Recdescent on fairly simple data, > but am getting stuck on capturing an escaped carriage return. > > I am not able to make too many assumptions about the structure of the data, > or I would probably just us a regexp. [...] > Words: /[\w\s\.\,]+/ { print "$item[1]\n"; } > EscCR: /\\\\n/ { print "$item[1]\n"; } > EscQt: /\\\"/ { print "$item[1]\n"; } > };
Here, /\\\\n/ matches only a single backslah, followed by an 'n'. To match two backslashes followed by an 'n', you need /\\\\\\\\n/. I guess this is because '\\' interpolates as a single backslash even in a single-quoted string. Here, the grammar is a single quoted string, and so one level of backslash interpolation occurs before the regexp is even processed by Parse::RecDescent; another level of interpolation occurs when the regexp is processed. TomP ------------------------------------------------------------------------- Tom Pollard [EMAIL PROTECTED] Schrodinger, Inc. 646-366-9555 x102 ------------------------------------------------------------------------- _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs