1Regexp::Common::list(3)User Contributed Perl DocumentatioRnegexp::Common::list(3)
2
3
4
6 Regexp::Common::list -- provide regexes for lists
7
9 use Regexp::Common qw /list/;
10
11 while (<>) {
12 /$RE{list}{-pat => '\w+'}/ and print "List of words";
13 /$RE{list}{-pat => $RE{num}{real}}/ and print "List of numbers";
14 }
15
17 Please consult the manual of Regexp::Common for a general description
18 of the works of this interface.
19
20 Do not use this module directly, but load it via Regexp::Common.
21
22 $RE{list}{-pat}{-sep}{-lastsep}
23
24 Returns a pattern matching a list of (at least two) substrings.
25
26 If "-pat=P" is specified, it defines the pattern for each substring in
27 the list. By default, P is "qr/.*?\S/". In Regexp::Common 0.02 or ear‐
28 lier, the default pattern was "qr/.*?/". But that will match a single
29 space, causing unintended parsing of "a, b, and c" as a list of four
30 elements instead of 3 (with "-word" being "(?:and)"). One consequence
31 is that a list of the form "a,,b" will no longer be parsed. Use the
32 pattern "qr /.*?/" to be able to parse this, but see the previous
33 remark.
34
35 If "-sep=P" is specified, it defines the pattern P to be used as a sep‐
36 arator between each pair of substrings in the list, except the final
37 two. By default P is "qr/\s*,\s*/".
38
39 If "-lastsep=P" is specified, it defines the pattern P to be used as a
40 separator between the final two substrings in the list. By default P
41 is the same as the pattern specified by the "-sep" flag.
42
43 For example:
44
45 $RE{list}{-pat=>'\w+'} # match a list of word chars
46 $RE{list}{-pat=>$RE{num}{real}} # match a list of numbers
47 $RE{list}{-sep=>"\t"} # match a tab-separated list
48 $RE{list}{-lastsep=>',\s+and\s+'} # match a proper English list
49
50 Under "-keep":
51
52 $1 captures the entire list
53
54 $2 captures the last separator
55
56 $RE{list}{conj}{-word=PATTERN}
57
58 An alias for $RE{list}{-lastsep=>'\s*,?\s*PATTERN\s*'}
59
60 If "-word" is not specified, the default pattern is "qr/and⎪or/".
61
62 For example:
63
64 $RE{list}{conj}{-word=>'et'} # match Jean, Paul, et Satre
65 $RE{list}{conj}{-word=>'oder'} # match Bonn, Koln oder Hamburg
66
67 $RE{list}{and}
68
69 An alias for $RE{list}{conj}{-word=>'and'}
70
71 $RE{list}{or}
72
73 An alias for $RE{list}{conj}{-word=>'or'}
74
76 $Log: list.pm,v $
77 Revision 2.103 2003/07/04 13:34:05 abigail
78 Fixed assignment to
79
80 Revision 2.102 2003/02/11 09:42:06 abigail
81 Added
82
83 Revision 2.101 2003/02/01 22:55:31 abigail
84 Changed Copyright years
85
86 Revision 2.100 2003/01/21 23:19:40 abigail
87 The whole world understands RCS/CVS version numbers, that 1.9 is an
88 older version than 1.10. Except CPAN. Curse the idiot(s) who think
89 that version numbers are floats (in which universe do floats have
90 more than one decimal dot?).
91 Everything is bumped to version 2.100 because CPAN couldn't deal
92 with the fact one file had version 1.10.
93
94 Revision 1.2 2002/08/05 12:16:59 abigail
95 Fixed 'Regex::' and 'Rexexp::' typos to 'Regexp::' (Found my Mike Castle).
96
97 Revision 1.1 2002/07/28 21:41:07 abigail
98 Split off from Regexp::Common.
99
101 Regexp::Common for a general description of how to use this interface.
102
104 Damian Conway (damian@conway.org)
105
107 This package is maintained by Abigail (regexp-common@abigail.nl).
108
110 Bound to be plenty.
111
112 For a start, there are many common regexes missing. Send them in to
113 regexp-common@abigail.nl.
114
116 Copyright (c) 2001 - 2003, Damian Conway. All Rights Reserved.
117 This module is free software. It may be used, redistributed
118 and/or modified under the terms of the Perl Artistic License
119 (see http://www.perl.com/perl/misc/Artistic.html)
120
121
122
123perl v5.8.8 2003-03-23 Regexp::Common::list(3)