-
-
14 Sep 2010 17:58:47 UTC
- Distribution: YAPE-Regex-Explain
- Module version: 4.01
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (2)
- Testers (848 / 31 / 0)
- Kwalitee
Bus factor: 0- 21.56% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (8.35KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Test::More
- YAPE::Regex
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
YAPE::Regex::Explain - explanation of a regular expression
VERSION
This document refers to YAPE::Regex::Explain version 4.01.
SYNOPSIS
use YAPE::Regex::Explain; my $exp = YAPE::Regex::Explain->new($REx)->explain;
YAPE
MODULESThe
YAPE
hierarchy of modules is an attempt at a unified means of parsing and extracting content. It attempts to maintain a generic interface, to promote simplicity and reusability. The API is powerful, yet simple. The modules do tokenization (which can be intercepted) and build trees, so that extraction of specific nodes is doable.DESCRIPTION
This module merely sub-classes
YAPE::Regex
, and produces a rather verbose explanation of a regex, suitable for demonstration and tutorial purposes.Methods for
YAPE::Regex::Explain
my $p = YAPE::Regex::Explain->new($regex);
Calls
YAPE::Regex
'snew
method (see its docs).my $p = YAPE::Regex::Explain->explain($mode);
Returns a string explaining the regex. While not required for all regexes, it is sometimes necessary to compile the regex using the
qr//
operator before passing it to theexplain
method. If$mode
isregex
, it will output a valid regex (instead of the normal string). If$mode
issilent
, no comments will be added, but the regex will be expanded into a readable format.
EXAMPLES
Print the full explanation for the regex
\Q[abc]\E\d+
, compiling it first:print YAPE::Regex::Explain->new(qr/\Q[abc]\E\d+/)->explain();
Print the explanation for the regex
\w[a-f]*
, without comments:print YAPE::Regex::Explain->new('\w[a-f]*')->explain('silent');
Print the explanation for a multi-line regex:
my $re = qr{ (foo|bar) # just a comment \d+ / }ix; print YAPE::Regex::Explain->new($re)->explain();
LIMITATIONS
There is no support for regular expression syntax added after Perl version 5.6, particularly any constructs added in 5.10. For examples, refer to:
http://perldoc.perl.org/perl5100delta.html#Regular-expressions
DEPENDENCIES
AUTHOR
The original author is Jeff "japhy" Pinyan (CPAN ID: PINYAN).
Gene Sullivan (gsullivan@cpan.org) is a co-maintainer.
LICENSE
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
Module Install Instructions
To install YAPE::Regex::Explain, copy and paste the appropriate command in to your terminal.
cpanm YAPE::Regex::Explain
perl -MCPAN -e shell install YAPE::Regex::Explain
For more information on module installation, please visit the detailed CPAN module installation guide.