X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FRegexp%2FWildcards.pm;h=0efd326d34f6b3f967e5f69f3890eb4953d97e08;hb=144ef10ec993ec83d9a42af3fb6d1577e44d4bb7;hp=59ac6d8c0f242516e4e631c514342f4534d882af;hpb=81c26bb06329658a6299f6d86df8cbaa9748f362;p=perl%2Fmodules%2FRegexp-Wildcards.git diff --git a/lib/Regexp/Wildcards.pm b/lib/Regexp/Wildcards.pm index 59ac6d8..0efd326 100644 --- a/lib/Regexp/Wildcards.pm +++ b/lib/Regexp/Wildcards.pm @@ -31,8 +31,10 @@ BEGIN { my $re; $re = $rw->convert('a{b?,c}*'); # Do it Unix shell style. $re = $rw->convert('a?,b*', 'win32'); # Do it Windows shell style. - $re = $rw->convert('*{x,y}?', 'jokers'); # Process the jokers and escape the rest. - $re = $rw->convert('%a_c%', 'sql'); # Turn SQL wildcards into regexps. + $re = $rw->convert('*{x,y}?', 'jokers'); # Process the jokers and + # escape the rest. + $re = $rw->convert('%a_c%', 'sql'); # Turn SQL wildcards into + # regexps. $rw = Regexp::Wildcards->new( do => [ qw ], # Do jokers and brackets. @@ -40,7 +42,8 @@ BEGIN { ); $rw->do(add => 'groups'); # Don't escape groups. - $rw->capture(rem => [ qw ]); # Actually we want non-greedy matches. + $rw->capture(rem => [ qw ]); # Actually we want non-greedy + # matches. $re = $rw->convert('*a{,(b)?}?c*'); # '(.*?)a(?:|(b).).c(.*?)' $rw->capture(); # No more captures. @@ -224,7 +227,10 @@ sub new { $self->capture($args{capture}); } -=head2 C<< new [ do => $what E type => $type ], capture => $captures >> +=head2 C + + my $rw = Regexp::Wildcards->new(do => $what, capture => $capture); + my $rw = Regexp::Wildcards->new(type => $type, capture => $capture); Constructs a new L object. @@ -238,7 +244,12 @@ The C option overrides C. C lists which atoms should be capturing. Refer to L for more details. -=head2 C<< do [ $what E set => $c1, add => $c2, rem => $c3 ] >> +=head2 C + + $rw->do($what); + $rw->do(set => $c1); + $rw->do(add => $c2); + $rw->do(rem => $c3); Specifies the list of metacharacters to convert or to prevent for escaping. They fit into six classes : @@ -328,12 +339,15 @@ No argument means C<< set => [ ] >>. $rw->do(set => 'jokers'); # Only translate jokers. $rw->do('jokers'); # Same. $rw->do(add => [ qw ]); # Translate also SQL and commas. - $rw->do(rem => 'jokers'); # Specifying both 'sql' and 'jokers' is useless. + $rw->do(rem => 'jokers'); # Specifying both 'sql' and + # 'jokers' is useless. $rw->do(); # Translate nothing. The C method returns the L object. -=head2 C +=head2 C + + $rw->type($type); Notifies to convert the metacharacters that corresponds to the predefined type C<$type>. C<$type> can be any of : @@ -386,7 +400,12 @@ In particular, you can usually pass C<$^O> as the C<$type> and get the correspon The C method returns the L object. -=head2 C<< capture [ $captures E set => $c1, add => $c2, rem => $c3 ] >> +=head2 C + + $rw->capture($captures); + $rw->capture(set => $c1); + $rw->capture(add => $c2); + $rw->capture(rem => $c3); Specifies the list of atoms to capture. This method works like L, except that the classes are different : @@ -430,15 +449,20 @@ Capture matching C<{ ... , ... }> alternations. =back - $rw->capture(set => 'single'); # Only capture "exactly one" metacharacters. + $rw->capture(set => 'single'); # Only capture "exactly one" + # metacharacters. $rw->capture('single'); # Same. - $rw->capture(add => [ qw ]); # Also greedily capture "any" metacharacters. + $rw->capture(add => [ qw ]); # Also greedily capture + # "any" metacharacters. $rw->capture(rem => 'greedy'); # No more greed please. $rw->capture(); # Capture nothing. The C method returns the L object. -=head2 C +=head2 C + + my $rx = $rw->convert($wc); + my $rx = $rw->convert($wc, $type); 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'>, 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. @@ -505,7 +529,8 @@ You can contact me by mail or on C (vincent). =head1 BUGS -Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. +Please report any bugs or feature requests to C, or through the web interface at L. +I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT @@ -517,7 +542,7 @@ Tests code coverage report is available at L