package re::engine::LPEG; use 5.010000; use XSLoader (); # All engines should subclass the core Regexp package our @ISA = 'Regexp'; BEGIN { $VERSION = '0.04'; XSLoader::load __PACKAGE__, $VERSION; } sub import { $^H{regcomp} = ENGINE; } sub unimport { delete $^H{regcomp} if $^H{regcomp} == ENGINE; } 1; __END__ =head1 NAME re::engine::LPEG - LPEG regular expression engine =head1 SYNOPSIS use re::engine::LPEG; if ('Hello, world' =~ m{ ( 'Hello' / 'Hi' ) ', ' { 'world' } }); print "Greetings, $1!"; } =head1 DESCRIPTION Replaces perl's regex engine in a given lexical scope with the LPeg one. See "Regex syntax for LPEG", on L. =head2 Common Pitfalls =over 4 =item * Literal string must be quoted or double quoted. Spaces are not significatives. =item * LPeg works only in I mode. So LPeg is unusable with C, and not suitable for C. =item * C<'/'> represents an ordered choice, so the syntax C<'m{pattern}'> is more readeable than C<'/pattern/'> where C<'/'> must be escaped. =item * Pre-defined character classes start by C<'%'> (like in the Lua string library). See L. =back =head1 AUTHORS FranEois PERRAD =head1 HOMEPAGE The development is hosted at L. =head1 COPYRIGHT Copyright 2008 FranEois PERRAD. This program is free software; you can redistribute it and/or modify it under the same terms as Lua & LPeg, see L. =cut