1Regexp::Pattern::ExamplUes(e3r)Contributed Perl DocumentRaetgieoxnp::Pattern::Example(3)
2
3
4
6 Regexp::Pattern::Example - An example Regexp::Pattern::* module
7
9 This document describes version 0.2.9 of Regexp::Pattern::Example (from
10 Perl distribution Regexp-Pattern), released on 2019-06-09.
11
13 use Regexp::Pattern; # exports re()
14 my $re = re("Example::re1");
15
17 Regexp::Pattern is a convention for organizing reusable regex patterns.
18
20 · re1
21
22 · re2
23
24 This is regexp for blah.
25
26 A longer description.
27
28 Examples:
29
30 "123-456" =~ re("Example::re2"); # matches
31
32 # Another example that matches
33 "123-456-78901" =~ re("Example::re2"); # matches
34
35 # An example that does not match
36 123456 =~ re("Example::re2"); # doesn't match
37
38 # An example that does not get tested
39 123456 =~ re("Example::re2"); # doesn't match
40
41 · re3
42
43 This is a regexp for blah blah.
44
45 ...
46
47 This is a dynamic pattern which will be generated on-demand.
48
49 The following arguments are available to customize the generated
50 pattern:
51
52 · variant
53
54 Choose variant.
55
56 Examples:
57
58 # An example that matches
59 "123-456" =~ re("Example::re3", {variant=>"A"}); # matches
60
61 # An example that doesn't match
62 "123-456" =~ re("Example::re3", {variant=>"B"}); # doesn't match
63
64 · re4
65
66 This is a regexp that does capturing.
67
68 Examples:
69
70 "123-456" =~ re("Example::re4"); # matches, $1=123, $2=456
71
72 "foo-bar" =~ re("Example::re4"); # doesn't match
73
74 · re5
75
76 This is another regexp that does (named) capturing and anchoring.
77
78 Examples:
79
80 "123-456" =~ re("Example::re5"); # matches, $+{"cap1"}=123, $+{"cap2"}=456
81
82 "something 123-456" =~ re("Example::re5"); # doesn't match
83
85 Please visit the project's homepage at
86 <https://metacpan.org/release/Regexp-Pattern>.
87
89 Source repository is at
90 <https://github.com/perlancar/perl-Regexp-Pattern>.
91
93 Please report any bugs or feature requests on the bugtracker website
94 <https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-Pattern>
95
96 When submitting a bug or request, please include a test-file or a patch
97 to an existing test-file that illustrates the bug or desired feature.
98
100 perlancar <perlancar@cpan.org>
101
103 This software is copyright (c) 2019, 2018, 2016 by perlancar@cpan.org.
104
105 This is free software; you can redistribute it and/or modify it under
106 the same terms as the Perl 5 programming language system itself.
107
108
109
110perl v5.30.0 2019-07-26 Regexp::Pattern::Example(3)