1package Regexp::Common;
2
3use 5.10.0;
4use strict;
5
6use warnings;
7no  warnings 'syntax';
8
9our $VERSION = '2017060201';
10our %RE;
11our %sub_interface;
12our $AUTOLOAD;
13
14
15sub _croak {
16    require Carp;
17    goto &Carp::croak;
18}
19
20sub _carp {
21    require Carp;
22    goto &Carp::carp;
23}
24
25sub new {
26    my ($class, @data) = @_;
27    my %self;
28    tie %self, $class, @data;
29    return \%self;
30}
31
32sub TIEHASH {
33    my ($class, @data) = @_;
34    bless \@data, $class;
35}
36
37sub FETCH {
38    my ($self, $extra) = @_;
39    return bless ref($self)->new(@$self, $extra), ref($self);
40}
41
42my %imports = map {$_ => "Regexp::Common::$_"}
43              qw /balanced CC     comment   delimited lingua list
44                  net      number profanity SEN       URI    whitespace
45                  zip/;
46
47sub import {
48    shift;  # Shift off the class.
49    tie %RE, __PACKAGE__;
50    {
51        no strict 'refs';
52        *{caller() . "::RE"} = \%RE;
53    }
54
55    my $saw_import;
56    my $no_defaults;
57    my %exclude;
58    foreach my $entry (grep {!/^RE_/} @_) {
59        if ($entry eq 'pattern') {
60            no strict 'refs';
61            *{caller() . "::pattern"} = \&pattern;
62            next;
63        }
64        # This used to prevent $; from being set. We still recognize it,
65        # but we won't do anything.
66        if ($entry eq 'clean') {
67            next;
68        }
69        if ($entry eq 'no_defaults') {
70            $no_defaults ++;
71            next;
72        }
73        if (my $module = $imports {$entry}) {
74            $saw_import ++;
75            eval "require $module;";
76            die $@ if $@;
77            next;
78        }
79        if ($entry =~ /^!(.*)/ && $imports {$1}) {
80            $exclude {$1} ++;
81            next;
82        }
83        # As a last resort, try to load the argument.
84        my $module = $entry =~ /^Regexp::Common/
85                            ? $entry
86                            : "Regexp::Common::" . $entry;
87        eval "require $module;";
88        die $@ if $@;
89    }
90
91    unless ($saw_import || $no_defaults) {
92        foreach my $module (values %imports) {
93            next if $exclude {$module};
94            eval "require $module;";
95            die $@ if $@;
96        }
97    }
98
99    my %exported;
100    foreach my $entry (grep {/^RE_/} @_) {
101        if ($entry =~ /^RE_(\w+_)?ALL$/) {
102            my $m  = defined $1 ? $1 : "";
103            my $re = qr /^RE_${m}.*$/;
104            while (my ($sub, $interface) = each %sub_interface) {
105                next if $exported {$sub};
106                next unless $sub =~ /$re/;
107                {
108                    no strict 'refs';
109                    *{caller() . "::$sub"} = $interface;
110                }
111                $exported {$sub} ++;
112            }
113        }
114        else {
115            next if $exported {$entry};
116            _croak "Can't export unknown subroutine &$entry"
117                unless $sub_interface {$entry};
118            {
119                no strict 'refs';
120                *{caller() . "::$entry"} = $sub_interface {$entry};
121            }
122            $exported {$entry} ++;
123        }
124    }
125}
126
127sub AUTOLOAD { _croak "Can't $AUTOLOAD" }
128
129sub DESTROY {}
130
131my %cache;
132
133my $fpat = qr/^(-\w+)/;
134
135sub _decache {
136        my @args = @{tied %{$_[0]}};
137        my @nonflags = grep {!/$fpat/} @args;
138        my $cache = get_cache(@nonflags);
139        _croak "Can't create unknown regex: \$RE{"
140            . join("}{",@args) . "}"
141                unless exists $cache->{__VAL__};
142        _croak "Perl $] does not support the pattern "
143            . "\$RE{" . join("}{",@args)
144            . "}.\nYou need Perl $cache->{__VAL__}{version} or later"
145                unless ($cache->{__VAL__}{version}||0) <= $];
146        my %flags = ( %{$cache->{__VAL__}{default}},
147                      map { /$fpat\Q$;\E(.*)/ ? ($1 => $2)
148                          : /$fpat/           ? ($1 => undef)
149                          :                     ()
150                          } @args);
151        $cache->{__VAL__}->_clone_with(\@args, \%flags);
152}
153
154use overload q{""} => \&_decache;
155
156
157sub get_cache {
158        my $cache = \%cache;
159        foreach (@_) {
160                $cache = $cache->{$_}
161                      || ($cache->{$_} = {});
162        }
163        return $cache;
164}
165
166sub croak_version {
167        my ($entry, @args) = @_;
168}
169
170sub pattern {
171        my %spec = @_;
172        _croak 'pattern() requires argument: name => [ @list ]'
173                unless $spec{name} && ref $spec{name} eq 'ARRAY';
174        _croak 'pattern() requires argument: create => $sub_ref_or_string'
175                unless $spec{create};
176
177        if (ref $spec{create} ne "CODE") {
178                my $fixed_str = "$spec{create}";
179                $spec{create} = sub { $fixed_str }
180        }
181
182        my @nonflags;
183        my %default;
184        foreach ( @{$spec{name}} ) {
185                if (/$fpat=(.*)/) {
186                        $default{$1} = $2;
187                }
188                elsif (/$fpat\s*$/) {
189                        $default{$1} = undef;
190                }
191                else {
192                        push @nonflags, $_;
193                }
194        }
195
196        my $entry = get_cache(@nonflags);
197
198        if ($entry->{__VAL__}) {
199                _carp "Overriding \$RE{"
200                   . join("}{",@nonflags)
201                   . "}";
202        }
203
204        $entry->{__VAL__} = bless {
205                                create  => $spec{create},
206                                match   => $spec{match} || \&generic_match,
207                                subs    => $spec{subs}  || \&generic_subs,
208                                version => $spec{version},
209                                default => \%default,
210                            }, 'Regexp::Common::Entry';
211
212        foreach (@nonflags) {s/\W/X/g}
213        my $subname = "RE_" . join ("_", @nonflags);
214        $sub_interface{$subname} = sub {
215                push @_ => undef if @_ % 2;
216                my %flags = @_;
217                my $pat = $spec{create}->($entry->{__VAL__},
218                               {%default, %flags}, \@nonflags);
219                if (exists $flags{-keep}) { $pat =~ s/\Q(?k:/(/g; }
220                else { $pat =~ s/\Q(?k:/(?:/g; }
221                return exists $flags {-i} ? qr /(?i:$pat)/ : qr/$pat/;
222        };
223
224        return 1;
225}
226
227sub generic_match {$_ [1] =~  /$_[0]/}
228sub generic_subs  {$_ [1] =~ s/$_[0]/$_[2]/}
229
230sub matches {
231        my ($self, $str) = @_;
232        my $entry = $self -> _decache;
233        $entry -> {match} -> ($entry, $str);
234}
235
236sub subs {
237        my ($self, $str, $newstr) = @_;
238        my $entry = $self -> _decache;
239        $entry -> {subs} -> ($entry, $str, $newstr);
240        return $str;
241}
242
243
244package Regexp::Common::Entry;
245# use Carp;
246
247use overload
248    q{""} => sub {
249        my ($self) = @_;
250        my $pat = $self->{create}->($self, $self->{flags}, $self->{args});
251        if (exists $self->{flags}{-keep}) {
252            $pat =~ s/\Q(?k:/(/g;
253        }
254        else {
255            $pat =~ s/\Q(?k:/(?:/g;
256        }
257        if (exists $self->{flags}{-i})   { $pat = "(?i)$pat" }
258        return $pat;
259    };
260
261sub _clone_with {
262    my ($self, $args, $flags) = @_;
263    bless { %$self, args=>$args, flags=>$flags }, ref $self;
264}
265
2661;
267
268__END__
269
270=pod
271
272=head1 NAME
273
274Regexp::Common - Provide commonly requested regular expressions
275
276=head1 SYNOPSIS
277
278 # STANDARD USAGE
279
280 use Regexp::Common;
281
282 while (<>) {
283     /$RE{num}{real}/               and print q{a number};
284     /$RE{quoted}/                  and print q{a ['"`] quoted string};
285    m[$RE{delimited}{-delim=>'/'}]  and print q{a /.../ sequence};
286     /$RE{balanced}{-parens=>'()'}/ and print q{balanced parentheses};
287     /$RE{profanity}/               and print q{a #*@%-ing word};
288 }
289
290
291 # SUBROUTINE-BASED INTERFACE
292
293 use Regexp::Common 'RE_ALL';
294
295 while (<>) {
296     $_ =~ RE_num_real()              and print q{a number};
297     $_ =~ RE_quoted()                and print q{a ['"`] quoted string};
298     $_ =~ RE_delimited(-delim=>'/')  and print q{a /.../ sequence};
299     $_ =~ RE_balanced(-parens=>'()'} and print q{balanced parentheses};
300     $_ =~ RE_profanity()             and print q{a #*@%-ing word};
301 }
302
303
304 # IN-LINE MATCHING...
305
306 if ( $RE{num}{int}->matches($text) ) {...}
307
308
309 # ...AND SUBSTITUTION
310
311 my $cropped = $RE{ws}{crop}->subs($uncropped);
312
313
314 # ROLL-YOUR-OWN PATTERNS
315
316 use Regexp::Common 'pattern';
317
318 pattern name   => ['name', 'mine'],
319         create => '(?i:J[.]?\s+A[.]?\s+Perl-Hacker)',
320         ;
321
322 my $name_matcher = $RE{name}{mine};
323
324 pattern name    => [ 'lineof', '-char=_' ],
325         create  => sub {
326                        my $flags = shift;
327                        my $char = quotemeta $flags->{-char};
328                        return '(?:^$char+$)';
329                    },
330         match   => sub {
331                        my ($self, $str) = @_;
332                        return $str !~ /[^$self->{flags}{-char}]/;
333                    },
334         subs   => sub {
335                        my ($self, $str, $replacement) = @_;
336                        $_[1] =~ s/^$self->{flags}{-char}+$//g;
337                   },
338         ;
339
340 my $asterisks = $RE{lineof}{-char=>'*'};
341
342 # DECIDING WHICH PATTERNS TO LOAD.
343
344 use Regexp::Common qw /comment number/;  # Comment and number patterns.
345 use Regexp::Common qw /no_defaults/;     # Don't load any patterns.
346 use Regexp::Common qw /!delimited/;      # All, but delimited patterns.
347
348
349=head1 DESCRIPTION
350
351By default, this module exports a single hash (C<%RE>) that stores or generates
352commonly needed regular expressions (see L<"List of available patterns">).
353
354There is an alternative, subroutine-based syntax described in
355L<"Subroutine-based interface">.
356
357
358=head2 General syntax for requesting patterns
359
360To access a particular pattern, C<%RE> is treated as a hierarchical hash of
361hashes (of hashes...), with each successive key being an identifier. For
362example, to access the pattern that matches real numbers, you
363specify:
364
365        $RE{num}{real}
366
367and to access the pattern that matches integers:
368
369        $RE{num}{int}
370
371Deeper layers of the hash are used to specify I<flags>: arguments that
372modify the resulting pattern in some way. The keys used to access these
373layers are prefixed with a minus sign and may have a value; if a value
374is given, it's done by using a multidimensional key.
375For example, to access the pattern that
376matches base-2 real numbers with embedded commas separating
377groups of three digits (e.g. 10,101,110.110101101):
378
379        $RE{num}{real}{-base => 2}{-sep => ','}{-group => 3}
380
381Through the magic of Perl, these flag layers may be specified in any order
382(and even interspersed through the identifier keys!)
383so you could get the same pattern with:
384
385        $RE{num}{real}{-sep => ','}{-group => 3}{-base => 2}
386
387or:
388
389        $RE{num}{-base => 2}{real}{-group => 3}{-sep => ','}
390
391or even:
392
393        $RE{-base => 2}{-group => 3}{-sep => ','}{num}{real}
394
395etc.
396
397Note, however, that the relative order of amongst the identifier keys
398I<is> significant. That is:
399
400        $RE{list}{set}
401
402would not be the same as:
403
404        $RE{set}{list}
405
406=head2 Flag syntax
407
408In versions prior to 2.113, flags could also be written as
409C<{"-flag=value"}>. This no longer works, although C<{"-flag$;value"}>
410still does. However, C<< {-flag => 'value'} >> is the preferred syntax.
411
412=head2 Universal flags
413
414Normally, flags are specific to a single pattern.
415However, there is two flags that all patterns may specify.
416
417=over 4
418
419=item C<-keep>
420
421By default, the patterns provided by C<%RE> contain no capturing
422parentheses. However, if the C<-keep> flag is specified (it requires
423no value) then any significant substrings that the pattern matches
424are captured. For example:
425
426        if ($str =~ $RE{num}{real}{-keep}) {
427                $number   = $1;
428                $whole    = $3;
429                $decimals = $5;
430        }
431
432Special care is needed if a "kept" pattern is interpolated into a
433larger regular expression, as the presence of other capturing
434parentheses is likely to change the "number variables" into which significant
435substrings are saved.
436
437See also L<"Adding new regular expressions">, which describes how to create
438new patterns with "optional" capturing brackets that respond to C<-keep>.
439
440=item C<-i>
441
442Some patterns or subpatterns only match lowercase or uppercase letters.
443If one wants the do case insensitive matching, one option is to use
444the C</i> regexp modifier, or the special sequence C<(?i)>. But if the
445functional interface is used, one does not have this option. The
446C<-i> switch solves this problem; by using it, the pattern will do
447case insensitive matching.
448
449=back
450
451=head2 OO interface and inline matching/substitution
452
453The patterns returned from C<%RE> are objects, so rather than writing:
454
455        if ($str =~ /$RE{some}{pattern}/ ) {...}
456
457you can write:
458
459        if ( $RE{some}{pattern}->matches($str) ) {...}
460
461For matching this would seem to have no great advantage apart from readability
462(but see below).
463
464For substitutions, it has other significant benefits. Frequently you want to
465perform a substitution on a string without changing the original. Most people
466use this:
467
468        $changed = $original;
469        $changed =~ s/$RE{some}{pattern}/$replacement/;
470
471The more adept use:
472
473        ($changed = $original) =~ s/$RE{some}{pattern}/$replacement/;
474
475Regexp::Common allows you do write this:
476
477        $changed = $RE{some}{pattern}->subs($original=>$replacement);
478
479Apart from reducing precedence-angst, this approach has the added
480advantages that the substitution behaviour can be optimized from the
481regular expression, and the replacement string can be provided by
482default (see L<"Adding new regular expressions">).
483
484For example, in the implementation of this substitution:
485
486        $cropped = $RE{ws}{crop}->subs($uncropped);
487
488the default empty string is provided automatically, and the substitution is
489optimized to use:
490
491        $uncropped =~ s/^\s+//;
492        $uncropped =~ s/\s+$//;
493
494rather than:
495
496        $uncropped =~ s/^\s+|\s+$//g;
497
498
499=head2 Subroutine-based interface
500
501The hash-based interface was chosen because it allows regexes to be
502effortlessly interpolated, and because it also allows them to be
503"curried". For example:
504
505        my $num = $RE{num}{int};
506
507        my $commad     = $num->{-sep=>','}{-group=>3};
508        my $duodecimal = $num->{-base=>12};
509
510
511However, the use of tied hashes does make the access to Regexp::Common
512patterns slower than it might otherwise be. In contexts where impatience
513overrules laziness, Regexp::Common provides an additional
514subroutine-based interface.
515
516For each (sub-)entry in the C<%RE> hash (C<$RE{key1}{key2}{etc}>), there
517is a corresponding exportable subroutine: C<RE_key1_key2_etc()>. The name of
518each subroutine is the underscore-separated concatenation of the I<non-flag>
519keys that locate the same pattern in C<%RE>. Flags are passed to the subroutine
520in its argument list. Thus:
521
522        use Regexp::Common qw( RE_ws_crop RE_num_real RE_profanity );
523
524        $str =~ RE_ws_crop() and die "Surrounded by whitespace";
525
526        $str =~ RE_num_real(-base=>8, -sep=>" ") or next;
527
528        $offensive = RE_profanity(-keep);
529        $str =~ s/$offensive/$bad{$1}++; "<expletive deleted>"/ge;
530
531Note that, unlike the hash-based interface (which returns objects), these
532subroutines return ordinary C<qr>'d regular expressions. Hence they do not
533curry, nor do they provide the OO match and substitution inlining described
534in the previous section.
535
536It is also possible to export subroutines for all available patterns like so:
537
538        use Regexp::Common 'RE_ALL';
539
540Or you can export all subroutines with a common prefix of keys like so:
541
542        use Regexp::Common 'RE_num_ALL';
543
544which will export C<RE_num_int> and C<RE_num_real> (and if you have
545create more patterns who have first key I<num>, those will be exported
546as well). In general, I<RE_key1_..._keyn_ALL> will export all subroutines
547whose pattern names have first keys I<key1> ... I<keyn>.
548
549
550=head2 Adding new regular expressions
551
552You can add your own regular expressions to the C<%RE> hash at run-time,
553using the exportable C<pattern> subroutine. It expects a hash-like list of
554key/value pairs that specify the behaviour of the pattern. The various
555possible argument pairs are:
556
557=over 4
558
559=item C<name =E<gt> [ @list ]>
560
561A required argument that specifies the name of the pattern, and any
562flags it may take, via a reference to a list of strings. For example:
563
564         pattern name => [qw( line of -char )],
565                 # other args here
566                 ;
567
568This specifies an entry C<$RE{line}{of}>, which may take a C<-char> flag.
569
570Flags may also be specified with a default value, which is then used whenever
571the flag is specified without an explicit value (but not when the flag is
572omitted). For example:
573
574         pattern name => [qw( line of -char=_ )],
575                 # default char is '_'
576                 # other args here
577                 ;
578
579
580=item C<create =E<gt> $sub_ref_or_string>
581
582A required argument that specifies either a string that is to be returned
583as the pattern:
584
585        pattern name    => [qw( line of underscores )],
586                create  => q/(?:^_+$)/
587                ;
588
589or a reference to a subroutine that will be called to create the pattern:
590
591        pattern name    => [qw( line of -char=_ )],
592                create  => sub {
593                                my ($self, $flags) = @_;
594                                my $char = quotemeta $flags->{-char};
595                                return '(?:^$char+$)';
596                            },
597                ;
598
599If the subroutine version is used, the subroutine will be called with
600three arguments: a reference to the pattern object itself, a reference
601to a hash containing the flags and their values,
602and a reference to an array containing the non-flag keys.
603
604Whatever the subroutine returns is stringified as the pattern.
605
606No matter how the pattern is created, it is immediately postprocessed to
607include or exclude capturing parentheses (according to the value of the
608C<-keep> flag). To specify such "optional" capturing parentheses within
609the regular expression associated with C<create>, use the notation
610C<(?k:...)>. Any parentheses of this type will be converted to C<(...)>
611when the C<-keep> flag is specified, or C<(?:...)> when it is not.
612It is a Regexp::Common convention that the outermost capturing parentheses
613always capture the entire pattern, but this is not enforced.
614
615
616=item C<match =E<gt> $sub_ref>
617
618An optional argument that specifies a subroutine that is to be called when
619the C<$RE{...}-E<gt>matches(...)> method of this pattern is invoked.
620
621The subroutine should expect two arguments: a reference to the pattern object
622itself, and the string to be matched against.
623
624It should return the same types of values as a C<m/.../> does.
625
626     pattern name    => [qw( line of -char )],
627             create  => sub {...},
628             match   => sub {
629                             my ($self, $str) = @_;
630                             $str !~ /[^$self->{flags}{-char}]/;
631                        },
632             ;
633
634
635=item C<subs =E<gt> $sub_ref>
636
637An optional argument that specifies a subroutine that is to be called when
638the C<$RE{...}-E<gt>subs(...)> method of this pattern is invoked.
639
640The subroutine should expect three arguments: a reference to the pattern object
641itself, the string to be changed, and the value to be substituted into it.
642The third argument may be C<undef>, indicating the default substitution is
643required.
644
645The subroutine should return the same types of values as an C<s/.../.../> does.
646
647For example:
648
649     pattern name    => [ 'lineof', '-char=_' ],
650             create  => sub {...},
651             subs    => sub {
652                          my ($self, $str, $ignore_replacement) = @_;
653                          $_[1] =~ s/^$self->{flags}{-char}+$//g;
654                        },
655             ;
656
657Note that such a subroutine will almost always need to modify C<$_[1]> directly.
658
659
660=item C<version =E<gt> $minimum_perl_version>
661
662If this argument is given, it specifies the minimum version of perl required
663to use the new pattern. Attempts to use the pattern with earlier versions of
664perl will generate a fatal diagnostic.
665
666=back
667
668=head2 Loading specific sets of patterns.
669
670By default, all the sets of patterns listed below are made available.
671However, it is possible to indicate which sets of patterns should
672be made available - the wanted sets should be given as arguments to
673C<use>. Alternatively, it is also possible to indicate which sets of
674patterns should not be made available - those sets will be given as
675argument to the C<use> statement, but are preceded with an exclaimation
676mark. The argument I<no_defaults> indicates none of the default patterns
677should be made available. This is useful for instance if all you want
678is the C<pattern()> subroutine.
679
680Examples:
681
682 use Regexp::Common qw /comment number/;  # Comment and number patterns.
683 use Regexp::Common qw /no_defaults/;     # Don't load any patterns.
684 use Regexp::Common qw /!delimited/;      # All, but delimited patterns.
685
686It's also possible to load your own set of patterns. If you have a
687module C<Regexp::Common::my_patterns> that makes patterns available,
688you can have it made available with
689
690 use Regexp::Common qw /my_patterns/;
691
692Note that the default patterns will still be made available - only if
693you use I<no_defaults>, or mention one of the default sets explicitly,
694the non mentioned defaults aren't made available.
695
696=head2 List of available patterns
697
698The patterns listed below are currently available. Each set of patterns
699has its own manual page describing the details. For each pattern set
700named I<name>, the manual page I<Regexp::Common::name> describes the
701details.
702
703Currently available are:
704
705=over 4
706
707=item Regexp::Common::balanced
708
709Provides regexes for strings with balanced parenthesized delimiters.
710
711=item Regexp::Common::comment
712
713Provides regexes for comments of various languages (43 languages
714currently).
715
716=item Regexp::Common::delimited
717
718Provides regexes for delimited strings.
719
720=item Regexp::Common::lingua
721
722Provides regexes for palindromes.
723
724=item Regexp::Common::list
725
726Provides regexes for lists.
727
728=item Regexp::Common::net
729
730Provides regexes for IPv4, IPv6, and MAC addresses.
731
732=item Regexp::Common::number
733
734Provides regexes for numbers (integers and reals).
735
736=item Regexp::Common::profanity
737
738Provides regexes for profanity.
739
740=item Regexp::Common::whitespace
741
742Provides regexes for leading and trailing whitespace.
743
744=item Regexp::Common::zip
745
746Provides regexes for zip codes.
747
748=back
749
750=head2 Forthcoming patterns and features
751
752Future releases of the module will also provide patterns for the following:
753
754        * email addresses
755        * HTML/XML tags
756        * more numerical matchers,
757        * mail headers (including multiline ones),
758        * more URLS
759        * telephone numbers of various countries
760        * currency (universal 3 letter format, Latin-1, currency names)
761        * dates
762        * binary formats (e.g. UUencoded, MIMEd)
763
764If you have other patterns or pattern generators that you think would be
765generally useful, please send them to the maintainer -- preferably as source
766code using the C<pattern> subroutine. Submissions that include a set of
767tests will be especially welcome.
768
769
770=head1 DIAGNOSTICS
771
772=over 4
773
774=item C<Can't export unknown subroutine %s>
775
776The subroutine-based interface didn't recognize the requested subroutine.
777Often caused by a spelling mistake or an incompletely specified name.
778
779
780=item C<Can't create unknown regex: $RE{...}>
781
782Regexp::Common doesn't have a generator for the requested pattern.
783Often indicates a misspelt or missing parameter.
784
785=item
786C<Perl %f does not support the pattern $RE{...}.
787You need Perl %f or later>
788
789The requested pattern requires advanced regex features (e.g. recursion)
790that not available in your version of Perl. Time to upgrade.
791
792=item C<< pattern() requires argument: name => [ @list ] >>
793
794Every user-defined pattern specification must have a name.
795
796=item C<< pattern() requires argument: create => $sub_ref_or_string >>
797
798Every user-defined pattern specification must provide a pattern creation
799mechanism: either a pattern string or a reference to a subroutine that
800returns the pattern string.
801
802=item C<Base must be between 1 and 36>
803
804The C<< $RE{num}{real}{-base=>'I<N>'} >> pattern uses the characters [0-9A-Z]
805to represent the digits of various bases. Hence it only produces
806regular expressions for bases up to hexatricensimal.
807
808=item C<Must specify delimiter in $RE{delimited}>
809
810The pattern has no default delimiter.
811You need to write: C<< $RE{delimited}{-delim=>I<X>'} >> for some character I<X>
812
813=back
814
815=head1 ACKNOWLEDGEMENTS
816
817Deepest thanks to the many people who have encouraged and contributed to this
818project, especially: Elijah, Jarkko, Tom, Nat, Ed, and Vivek.
819
820Further thanks go to: Alexandr Ciornii, Blair Zajac, Bob Stockdale,
821Charles Thomas, Chris Vertonghen, the CPAN Testers, David Hand,
822Fany, Geoffrey Leach, Hermann-Marcus Behrens, Jerome Quelin, Jim Cromie,
823Lars Wilke, Linda Julien, Mike Arms, Mike Castle, Mikko, Murat Uenalan,
824RafaE<235>l Garcia-Suarez, Ron Savage, Sam Vilain, Slaven Rezic, Smylers,
825Tim Maher, and all the others I've forgotten.
826
827=head1 AUTHOR
828
829Damian Conway (damian@conway.org)
830
831=head1 MAINTENANCE
832
833This package is maintained by Abigail S<(I<regexp-common@abigail.be>)>.
834
835=head1 BUGS AND IRRITATIONS
836
837Bound to be plenty.
838
839For a start, there are many common regexes missing.
840Send them in to I<regexp-common@abigail.be>.
841
842There are some POD issues when installing this module using a pre-5.6.0 perl;
843some manual pages may not install, or may not install correctly using a perl
844that is that old. You might consider upgrading your perl.
845
846=head1 NOT A BUG
847
848=over 4
849
850=item *
851
852The various patterns are not anchored. That is, a pattern like
853C<< $RE {num} {int} >> will match against "abc4def", because a
854substring of the subject matches. This is by design, and not a
855bug. If you want the pattern to be anchored, use something like:
856
857 my $integer = $RE {num} {int};
858 $subj =~ /^$integer$/ and print "Matches!\n";
859
860=back
861
862=head1 LICENSE and COPYRIGHT
863
864This software is Copyright (c) 2001 - 2017, Damian Conway and Abigail.
865
866This module is free software, and maybe used under any of the following
867licenses:
868
869 1) The Perl Artistic License.     See the file COPYRIGHT.AL.
870 2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
871 3) The BSD License.               See the file COPYRIGHT.BSD.
872 4) The MIT License.               See the file COPYRIGHT.MIT.
873