X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FRegexp%2FWildcards.pm;h=abb59f0fefde1543312419d3a3a3f4cca5205a63;hb=a86792e2f3991cbfdda962a94f851bfb44e9ed8e;hp=f0b471a8be5cea353f87254b5e3c164849e703db;hpb=9375fddef45f4884a1e447e6d31f608ce18b22a2;p=perl%2Fmodules%2FRegexp-Wildcards.git diff --git a/lib/Regexp/Wildcards.pm b/lib/Regexp/Wildcards.pm index f0b471a..abb59f0 100644 --- a/lib/Regexp/Wildcards.pm +++ b/lib/Regexp/Wildcards.pm @@ -399,10 +399,12 @@ C<'brackets'> will capture matching C<{ ... , ... }> alternations. $rw->capture(rem => 'greedy'); # No more greed please. $rw->capture(); # Capture nothing. +The C method returns the L object. + =head2 C Converts the wildcard expression C<$wc> into a regular expression according to the options stored into the L object, or to C<$type> if it's supplied. -It successively escapes all unprotected regexp special characters that doesn't hold any meaning for wildcards, then replace C<'jokers'> or C<'sql'> and C<'commas'> or C<'brackets'> (depending on the L or L options), all of this by applying the C<'capture'> rules specified in the constructor or by L. +It successively escapes all unprotected regexp special characters that doesn't hold any meaning for wildcards, then replace C<'jokers'>, C<'sql'> and C<'commas'> or C<'brackets'> (depending on the L or L options), all of this by applying the C<'capture'> rules specified in the constructor or by L. =cut @@ -411,21 +413,32 @@ sub convert { _check_self $self; my $config = (defined $type) ? $self->_type($type) : $self; return unless defined $wc; + + my $e = $config->{escape}; + # Escape : + # - an even number of \ that doesn't protect a regexp/wildcard metachar + # - an odd number of \ that doesn't protect a wildcard metachar + $wc =~ s/ + (?{do}; - my $e = $config->{escape}; - $wc =~ s/(?{jokers}) { - $wc = $self->_jokers($wc); - } elsif ($do->{sql}) { - $wc = $self->_sql($wc); - } + $wc = $self->_jokers($wc) if $do->{jokers}; + $wc = $self->_sql($wc) if $do->{sql}; if ($do->{brackets}) { $wc = $self->_bracketed($wc); - } elsif ($do->{commas}) { - if ($wc =~ /(?{'c_brackets'} . $self->_commas($wc) . ')'; - } + } elsif ($do->{commas} and $wc =~ /(?{'c_brackets'} . $self->_commas($wc) . ')'; } + return $wc; } @@ -478,8 +491,6 @@ sub _extract ($) { extract_bracketed $_[0], '{', qr/.*?(?{c_single}; s/(?{c_single}; s/(?