GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  YAPE::REGEX::ELEMENT (3)

.ds Aq ’

NAME

YAPE::Regex::Element - sub-classes for YAPE::Regex elements

CONTENTS

VERSION

This document refers to YAPE::Regex::Element version 4.00.

SYNOPSIS



  use YAPE::Regex MyExt::Mod;
  # this sets up inheritence in MyExt::Mod
  # see YAPE::Regex documentation



YAPE MODULES

The 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 provides the classes for the YAPE::Regex objects. The base class for these objects is YAPE::Regex::Element. The objects classes are numerous.

Methods for CWYAPE::Regex::Element

This class contains fallback methods for the other classes.
o my $str = $obj->text;

Returns a string representation of the content of the regex node itself, not any nodes contained in it. This is undef for non-text nodes.

o my $str = $obj->string;

Returns a string representation of the regex node itself, not any nodes contained in it.

o my $str = $obj->fullstring;

Returns a string representation of the regex node, including any nodes contained in it.

o my $quant = $obj->quant;

Returns a string with the quantity, and a ? if the node is non-greedy. The quantity is one of *, +, ?, {M,N}, or an empty string.

o my $ng = $obj->ngreed;

Returns a ? if the node is non-greedy, and an empty string otherwise.

Methods for CWYAPE::Regex::anchor

This class represents anchors. Objects have the following methods:
o my $anchor = YAPE::Regex::anchor->new($type,$q,$ng);

Creates a YAPE::Regex::anchor object. Takes three arguments: the anchor (^, \A, $, \Z, \z, \B, \b, or \G), the quantity, and the non-greedy flag. The quantity should be an empty string.



  my $anc = YAPE::Regex::anchor->new(\A, , ?);
  # /\A?/



o my $type = $anchor->type;

Returns the string anchor.

Methods for CWYAPE::Regex::macro

This class represents character-class macros. Objects have the following methods:
o my $macro = YAPE::Regex::macro->new($type,$q,$ng);

Creates a YAPE::Regex::macro object. Takes three arguments: the macro (w, W, d, D, s, or S), the quantity, and the non-greedy flag.



  my $macro = YAPE::Regex::macro->new(s, {3,5});
  # /\s{3,5}/



o my $text = $macro->text;

Returns the macro.



  print $macro->text;  # \s



o my $type = $macro->type;

Returns the string macro.

Methods for CWYAPE::Regex::oct

This class represents octal escapes. Objects have the following methods:
o my $oct = YAPE::Regex::oct->new($type,$q,$ng);

Creates a YAPE::Regex::oct object. Takes three arguments: the octal number (as a string), the quantity, and the non-greedy flag.



  my $oct = YAPE::Regex::oct->new(040);
  # /\040/



o my $text = $oct->text;

Returns the octal escape.



  print $oct->text;  # \040



o my $type = $oct->type;

Returns the string oct.

Methods for CWYAPE::Regex::hex

This class represents hexadecimal escapes. Objects have the following methods:
o my $hex = YAPE::Regex::hex->new($type,$q,$ng);

Creates a YAPE::Regex::hex object. Takes three arguments: the hexadecimal number (as a string), the quantity, and the non-greedy flag.



  my $hex = YAPE::Regex::hex->new(20,{2,});
  # /\x20{2,}/



o my $text = $hex->text;

Returns the hexadecimal escape.



  print $hex->text;  # \x20



o my $type = $hex->type;

Returns the string hex.

Methods for CWYAPE::Regex::utf8hex

This class represents UTF hexadecimal escapes. Objects have the following methods:
o my $hex = YAPE::Regex::utf8hex->new($type,$q,$ng);

Creates a YAPE::Regex::utf8hex object. Takes three arguments: the hexadecimal number (as a string), the quantity, and the non-greedy flag.



  my $utf8hex = YAPE::Regex::utf8hex->new(beef,{0,4});
  # /\x{beef}{2,}/



o my $text = $utf8hex->text;

Returns the hexadecimal escape.



  print $utf8hex->text;  # \x{beef}



o my $type = $utf8hex->type;

Returns the string utf8hex.

Methods for CWYAPE::Regex::backref

This class represents back-references. Objects have the following methods:
o my $bref = YAPE::Regex::bref->new($type,$q,$ng);

Creates a YAPE::Regex::bref object. Takes three arguments: the number of the back-reference, the quantity, and the non-greedy flag.



  my $bref = YAPE::Regex::bref->new(2,,?);
  # /\2?/



o my $text = $bref->text;

Returns the backescape.



  print $bref->text;  # \2



o my $type = $bref->type;

Returns the string backref.

Methods for CWYAPE::Regex::ctrl

This class represents control character escapes. Objects have the following methods:
o my $ctrl = YAPE::Regex::ctrl->new($type,$q,$ng);

Creates a YAPE::Regex::ctrl object. Takes three arguments: the control character, the quantity, and the non-greedy flag.



  my $ctrl = YAPE::Regex::ctrl->new(M);
  # /\cM/



o my $text = $ctrl->text;

Returns the control character escape.



  print $ctrl->text;  # \cM



o my $type = $ctrl->type;

Returns the string ctrl.

Methods for CWYAPE::Regex::named

This class represents named characters. Objects have the following methods:
o my $ctrl = YAPE::Regex::named->new($type,$q,$ng);

Creates a YAPE::Regex::named object. Takes three arguments: the name of the character, the quantity, and the non-greedy flag.



  my $named = YAPE::Regex::named->new(GREEK SMALL LETTER BETA);
  # /\N{GREEK SMALL LETTER BETA}/



o my $text = $named->text;

Returns the character escape text.



  print $named->text;  # \N{GREEK SMALL LETTER BETA}



o my $type = $named->type;

Returns the string named.

Methods for CWYAPE::Regex::Cchar

This class represents C characters. Objects have the following methods:
o my $ctrl = YAPE::Regex::Cchar->new($q,$ng);

Creates a YAPE::Regex::Cchar object. Takes two arguments: the quantity and the non-greedy flag.



  my $named = YAPE::Regex::Char->new(2);
  # /\C{2}/



o my $text = $Cchar->text;

Returns the escape sequence.



  print $Cchar->text;  # \C



o my $type = $Cchar->type;

Returns the string Cchar.

Methods for CWYAPE::Regex::slash

This class represents any other escaped characters. Objects have the following methods:
o my $slash = YAPE::Regex::slash->new($type,$q,$ng);

Creates a YAPE::Regex::slash object. Takes three arguments: the backslashed character, the quantity, and the non-greedy flag.



  my $slash = YAPE::Regex::slash->new(t,,?);
  # /\t?/



o my $text = $slash->text;

Returns the escaped character.



  print $slash->text;  # \t



o my $type = $slash->type;

Returns the string slash.

Methods for CWYAPE::Regex::any

This class represents the dot metacharacter. Objects have the following methods:
o my $any = YAPE::Regex::any->new($q,$ng);

Creates a YAPE::Regex::any object. Takes two arguments: the quantity, and the non-greedy flag.



  my $any = YAPE::Regex::any->new({1,3});
  # /.{1,3}/



o my $type = $any->type;

Returns the string any.

Methods for CWYAPE::Regex::class

This class represents character classes. Objects have the following methods:
o my $class = YAPE::Regex::class->new($chars,$neg,$q,$ng);

Creates a YAPE::Regex::class object. Takes four arguments: the characters in the class, a ^ if the class is negated (an empty string otherwise), the quantity, and the non-greedy flag.



  my $class = YAPE::Regex::class->new(aeiouy,^);
  # /[^aeiouy]/



o my $text = $class->text;

Returns the character class.



  print $class->text;  # [^aeiouy]



o my $type = $class->type;

Returns the string class.

Methods for CWYAPE::Regex::hex

This class represents hexadecimal escapes. Objects have the following methods:
o my $text = YAPE::Regex::text->new($text,$q,$ng);

Creates a YAPE::Regex::text object. Takes three arguments: the text, the quantity, and the non-greedy flag. The quantity and non-greedy modifier should only be present for single-character text, because of the way the parser renders the quantity and non-greedy modifier.



  my $text = YAPE::Regex::text->new(alphabet,);
  # /alphabet/
 
  my $text = YAPE::Regex::text->new(x,?,?);
  # /x??/



o my $type = $text->type;

Returns the string text.

Methods for CWYAPE::Regex::alt

This class represents alternation. Objects have the following methods:
o my $alt = YAPE::Regex::alt->new;

Creates a YAPE::Regex::alt object.



  my $alt = YAPE::Regex::alt->new;
  # /|/



o my $type = $oct->type;

Returns the string alt.

Methods for CWYAPE::Regex::comment

This class represents in-line comments. Objects have the following methods:
o my $comment = YAPE::Regex::comment->new($comment,$x);

Creates a YAPE::Regex::comment object. Takes two arguments: the text of the comment, and whether or not the /x regex modifier is in effect for this comment. Note that Perl’s regex engine will stop a (?#...) comment at the first ), regardless of what you do.



  my $comment = YAPE::Regex::comment->new(
    "match an optional string of digits"
  );
  # /(?#match an optional string of digits)/

  my $comment = YAPE::Regex::comment->new(
    "match an optional string of digits",
    1
  );
  # /# match an optional string of digits/



o my $type = $comment->type;

Returns the string comment.

o my $x_on = $comment->xcomm;

Returns true or false, depending on whether the comment is under the /x regex modifier.

Methods for CWYAPE::Regex::whitespace

This class represents whitespace under the /x regex modifier. Objects have the following methods:
o my $ws = YAPE::Regex::whitespace->new($text);

Creates a YAPE::Regex::whitespace object. Takes one argument: the text of the whitespace.



  my $ws = YAPE::Regex::whitespace->new(  );
  # /  /x



o my $text = $ws->text;

Returns the whitespace.



  print $ws->text;  #   



o my $type = $ws->type;

Returns the string whitespace.

Methods for CWYAPE::Regex::flags

This class represents (?ismx) flags. Objects have the following methods:
o my $flags = YAPE::Regex::flags->new($add,$sub);

Creates a YAPE::Regex::flags object. Takes two arguments: a string of the modes to have on, and a string of the modes to explicitly turn off. The flags are displayed in alphabetical order.



  my $flags = YAPE::Regex::flags->new(is,m);
  # /(?is-m)/



o my $type = $flags->type;

Returns the string flags.

Methods for CWYAPE::Regex::cut

This class represents the cut assertion. Objects have the following methods:
o my $look = YAPE::Regex::cut->new(\@nodes);

Creates a YAPE::Regex::cut object. Takes one arguments: a reference to an array of objects to be contained in the cut.



  my $REx = YAPE::Regex::class->new(aeiouy,,+);
  my $look = YAPE::Regex::cut->new(0,[$REx]);
  # /(?>[aeiouy]+)/



o my $type = $cut->type;

Returns the string cut.

Methods for CWYAPE::Regex::lookahead

This class represents lookaheads. Objects have the following methods:
o my $look = YAPE::Regex::lookahead->new($pos,\@nodes);

Creates a YAPE::Regex::lookahead object. Takes two arguments: a boolean value indicating whether or not the lookahead is positive, and a reference to an array of objects to be contained in the lookahead.



  my $REx = YAPE::Regex::class->new(aeiouy);
  my $look = YAPE::Regex::lookahead->new(0,[$REx]);
  # /(?![aeiouy])/



o my $pos = $look->pos;

Returns true if the lookahead is positive.



  print $look->pos ? pos : neg;  # neg



o my $type = $look->type;

Returns the string lookahead(pos) or lookahead(neg).

Methods for CWYAPE::Regex::lookbehind

This class represents lookbehinds. Objects have the following methods:
o my $look = YAPE::Regex::lookbehind->new($pos,\@nodes);

Creates a YAPE::Regex::lookbehind object. Takes two arguments: a boolean value indicating whether or not the lookbehind is positive, and a reference to an array of objects to be contained in the lookbehind.



  my $REx = YAPE::Regex::class->new(aeiouy,^);
  my $look = YAPE::Regex::lookbehind->new(1,[$REx]);
  # /(?<=[^aeiouy])/



o my $pos = $look->pos;

Returns true if the lookbehind is positive.



  print $look->pos ? pos : neg;  # pos



o my $type = $look->type;

Returns the string lookbehind(pos) or lookbehind(neg).

Methods for CWYAPE::Regex::conditional

This class represents conditionals. Objects have the following methods:
o my $cond = YAPE::Regex::conditional->new($br,$t,$f,$q,$ng);

Creates a YAPE::Regex::hex object. Takes five arguments: the number of the back-reference (that’s all that’s supported in the current version), an array reference to the true pattern, an array reference to the false pattern, and the quantity and non-greedy flag.



  my $cond = YAPE::Regex::conditional->new(
    2,
    [],
    [ YAPE::Regex::text->new(foo) ],
    ?,
  );
  # /(?(2)|foo)?/



o my $br = $cond->backref;

Returns the number of the back-reference the conditional depends on.



  print $br->backref;  # 2



o my $type = $cond->type;

Returns the string conditional(N), where N is the number of the back-reference.

Methods for CWYAPE::Regex::group

This class represents non-capturing groups. Objects have the following methods:
o my $group = YAPE::Regex::group->new($on,$off,\@nodes,$q,$ng);

Creates a YAPE::Regex::group object. Takes five arguments: the modes turned on, the modes explicitly turned off, a reference to an array of objects in the group, the quantity, and the non-greedy flag. The modes are displayed in alphabetical order.



  my $group = YAPE::Regex::group->new(
    i,
    s,
    [
      YAPE::Regex::macro->new(d, {2}),
      YAPE::Regex::macro->new(s),
      YAPE::Regex::macro->new(d, {2}),
    ],
    ?,
  );
  # /(?i-s:\d{2}\s\d{2})?/



o my $type = $group->type;

Returns the string group.

Methods for CWYAPE::Regex::capture

This class represents capturing groups. Objects have the following methods:
o my $capture = YAPE::Regex::capture->new(\@nodes,$q,$ng);

Creates a YAPE::Regex::capture object. Takes three arguments: a reference to an array of objects in the group, the quantity, and the non-greedy flag.



  my $capture = YAPE::Regex::capture->new(
    [
      YAPE::Regex::macro->new(d, {2}),
      YAPE::Regex::macro->new(s),
      YAPE::Regex::macro->new(d, {2}),
    ],
  );
  # /(\d{2}\s\d{2})/



o my $type = $capture->type;

Returns the string capture.

Methods for CWYAPE::Regex::code

This class represents code blocks. Objects have the following methods:
o my $code = YAPE::Regex::code->new($block);

Creates a YAPE::Regex::code object. Takes one arguments: a string holding a block of code.



  my $code = YAPE::Regex::code->new(q({ push @poss, $1 }));
  # /(?{ push @poss, $1 })/



o my $type = $code->type;

Returns the string code.

Methods for CWYAPE::Regex::later

This class represents closed parentheses. Objects have the following methods:
o my $later = YAPE::Regex::later->new($block);

Creates a YAPE::Regex::later object. Takes one arguments: a string holding a block of code.



  my $later = YAPE::Regex::later->new(q({ push @poss, $1 }));
  # /(?{{ push @poss, $1 }})/



o my $type = $later->type;

Returns the string later.

Methods for CWYAPE::Regex::close

This class represents closed parentheses. Objects have the following methods:
o my $close = YAPE::Regex::close->new($q,$ng);

Creates a YAPE::Regex::close object. Takes two arguments: the quantity, and the non-greedy flag. This object is never needed in the tree; however, they are returned in the parsing stage, so that you know when they’ve been reached.



  my $close = YAPE::Regex::close->new(?,?);
  # /)??/



o my $type = $close->type;

Returns the string close.

TO DO

This is a listing of things to add to future versions of this module.
o None!

BUGS

Following is a list of known or reported bugs.
o This documentation might be incomplete.

SUPPORT

Visit YAPE’s web site at http://www.pobox.com/~japhy/YAPE/.

SEE ALSO

The YAPE::Regex documentation, for information on the main class.

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.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 REGEX::ELEMENT (3) 2011-02-02

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.