1Regexp::Common::balanceUds(e3r)Contributed Perl DocumentRaetgieoxnp::Common::balanced(3)
2
3
4

NAME

6       Regexp::Common::balanced -- provide regexes for strings with balanced
7       parenthesized delimiters or arbitrary delimiters.
8

SYNOPSIS

10           use Regexp::Common qw /balanced/;
11
12           while (<>) {
13               /$RE{balanced}{-parens=>'()'}/
14                                          and print q{balanced parentheses\n};
15           }
16

DESCRIPTION

18       Please consult the manual of Regexp::Common for a general description
19       of the works of this interface.
20
21       Do not use this module directly, but load it via Regexp::Common.
22
23   $RE{balanced}{-parens}
24       Returns a pattern that matches a string that starts with the nominated
25       opening parenthesis or bracket, contains characters and properly nested
26       parenthesized subsequences, and ends in the matching parenthesis.
27
28       More than one type of parenthesis can be specified:
29
30               $RE{balanced}{-parens=>'(){}'}
31
32       in which case all specified parenthesis types must be correctly
33       balanced within the string.
34
35       If we are using C{-keep} (See Regexp::Common):
36
37       $1  captures the entire expression
38
39   $RE{balanced}{-begin => "begin"}{-end => "end"}
40       Returns a pattern that matches a string that is properly balanced using
41       the begin and end strings as start and end delimiters.  Multiple sets
42       of begin and end strings can be given by separating them by "|"s (which
43       can be escaped with a backslash).
44
45           qr/$RE{balanced}{-begin => "do|if|case"}{-end => "done|fi|esac"}/
46
47       will match properly balanced strings that either start with do and end
48       with done, start with if and end with fi, or start with case and end
49       with esac.
50
51       If -end contains less cases than -begin, the last case of -end is
52       repeated. If it contains more cases than -begin, the extra cases are
53       ignored. If either of -begin or -end isn't given, or is empty, -begin
54       => '(' and -end => ')' are assumed.
55
56       If we are using C{-keep} (See Regexp::Common):
57
58       $1  captures the entire expression
59

SEE ALSO

61       Regexp::Common for a general description of how to use this interface.
62

AUTHOR

64       Damian Conway (damian@conway.org)
65

MAINTAINANCE

67       This package is maintained by Abigail (regexp-common@abigail.be).
68

BUGS AND IRRITATIONS

70       Bound to be plenty.
71
72       For a start, there are many common regexes missing.  Send them in to
73       regexp-common@abigail.be.
74
76       This software is Copyright (c) 2001 - 2009, Damian Conway and Abigail.
77
78       This module is free software, and maybe used under any of the following
79       licenses:
80
81        1) The Perl Artistic License.     See the file COPYRIGHT.AL.
82        2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
83        3) The BSD Licence.               See the file COPYRIGHT.BSD.
84        4) The MIT Licence.               See the file COPYRIGHT.MIT.
85
86
87
88perl v5.12.0                      2010-01-02       Regexp::Common::balanced(3)
Impressum