line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Wildcard::SQL; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
4
|
|
|
|
|
|
|
our $DATE = '2020-02-09'; # DATE |
5
|
|
|
|
|
|
|
our $DIST = 'String-Wildcard-SQL'; # DIST |
6
|
|
|
|
|
|
|
our $VERSION = '0.030'; # VERSION |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
98886
|
use 5.010001; |
|
1
|
|
|
|
|
13
|
|
9
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
35
|
|
10
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
231
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
14
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
15
|
|
|
|
|
|
|
$RE_WILDCARD_SQL |
16
|
|
|
|
|
|
|
contains_wildcard |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $RE_WILDCARD_SQL = |
20
|
|
|
|
|
|
|
qr/ |
21
|
|
|
|
|
|
|
# (?: |
22
|
|
|
|
|
|
|
# # non-empty, non-escaped character class |
23
|
|
|
|
|
|
|
# (?<!\\)(?:\\\\)*\[ |
24
|
|
|
|
|
|
|
# (?: \\\\ | \\\[ | \\\] | [^\\\[\]] )+ |
25
|
|
|
|
|
|
|
# (?<!\\)(?:\\\\)*\] |
26
|
|
|
|
|
|
|
# ) |
27
|
|
|
|
|
|
|
#| |
28
|
|
|
|
|
|
|
(?: |
29
|
|
|
|
|
|
|
# non-escaped % and _ |
30
|
|
|
|
|
|
|
(?P<sql_joker> |
31
|
|
|
|
|
|
|
(?<!\\)(?:\\\\)*[_%] |
32
|
|
|
|
|
|
|
) |
33
|
|
|
|
|
|
|
| |
34
|
|
|
|
|
|
|
(?P<literal> |
35
|
|
|
|
|
|
|
.+? |
36
|
|
|
|
|
|
|
) |
37
|
|
|
|
|
|
|
) |
38
|
|
|
|
|
|
|
/ox; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub contains_wildcard { |
41
|
8
|
|
|
8
|
1
|
9420
|
my $str = shift; |
42
|
|
|
|
|
|
|
|
43
|
8
|
|
|
|
|
57
|
while ($str =~ /$RE_WILDCARD_SQL/go) { |
44
|
1
|
|
|
1
|
|
478
|
my %m = %+; |
|
1
|
|
|
|
|
425
|
|
|
1
|
|
|
|
|
73
|
|
|
23
|
|
|
|
|
151
|
|
45
|
23
|
100
|
|
|
|
127
|
return 1 if $m{sql_joker}; |
46
|
|
|
|
|
|
|
} |
47
|
4
|
|
|
|
|
19
|
0; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
# ABSTRACT: SQL wildcard string routines |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=pod |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=encoding UTF-8 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
String::Wildcard::SQL - SQL wildcard string routines |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 VERSION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This document describes version 0.030 of String::Wildcard::SQL (from Perl distribution String-Wildcard-SQL), released on 2020-02-09. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SYNOPSIS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use String::Wildcard::SQL qw(contains_wildcard); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
say 1 if contains_wildcard("")); # -> 0 |
72
|
|
|
|
|
|
|
say 1 if contains_wildcard("ab%")); # -> 1 |
73
|
|
|
|
|
|
|
say 1 if contains_wildcard("ab\\%")); # -> 0 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 DESCRIPTION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 VARIABLES |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 $RE_WILDCARD_SQL |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 FUNCTIONS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 contains_wildcard($str[, $variant]) => bool |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Return true if C<$str> contains wildcard pattern. Wildcard patterns include C<%> |
86
|
|
|
|
|
|
|
(meaning zero or more characters) and C<_> (exactly one character). |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 HOMEPAGE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/String-Wildcard-SQL>. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SOURCE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-String-Wildcard-SQL>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 BUGS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=String-Wildcard-SQL> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
101
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
102
|
|
|
|
|
|
|
feature. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
L<Regexp::Wildcards> to convert a string with wildcard pattern to equivalent |
107
|
|
|
|
|
|
|
regexp pattern. Can handle Unix wildcards as well as SQL and DOS/Win32. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Other C<String::Wildcard::*> modules. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This software is copyright (c) 2020, 2015 by perlancar@cpan.org. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
120
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |