Regexp::Wildcards

Regexp::Wildcards is a Perl module that converts wildcard expressions to Perl regular expressions.
Download

Regexp::Wildcards Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Vincent Pit
  • Publisher web site:
  • http://search.cpan.org/~vpit/

Regexp::Wildcards Tags


Regexp::Wildcards Description

Regexp::Wildcards is a Perl module that converts wildcard expressions to Perl regular expressions. Regexp::Wildcards is a Perl module that converts wildcard expressions to Perl regular expressions.SYNOPSIS use Regexp::Wildcards qw/wc2re/; my $re; $re = wc2re 'a{b?,c}*' => 'unix'; # Do it Unix style. $re = wc2re 'a?,b*' => 'win32'; # Do it Windows style. $re = wc2re '*{x,y}?' => 'jokers'; # Process the jokers & escape the rest. $re = wc2re '%a_c%' => 'sql'; # Turn SQL wildcards into regexps.In many situations, users may want to specify patterns to match but don't need the full power of regexps. Wildcards make one of those sets of simplified rules. This module converts wildcard expressions to Perl regular expressions, so that you can use them for matching. It handles the * and ? shell jokers, as well as Unix bracketed alternatives {,}, but also % and _ SQL wildcards. Backspace () is used as an escape character. Wrappers are provided to mimic the behaviour of Windows and Unix shells.VARIABLESThese variables control if the wildcards jokers and brackets must capture their match. They can be globally set by writing in your program $Regexp::Wildcards::CaptureSingle = 1; # From then, "exactly one" wildcards are capturingor can be locally specified via local { local $Regexp::Wildcards::CaptureSingle = 1; # In this block, "exactly one" wildcards are capturing. ... } # Back to the situation from before the blockThis section describes also how those elements are translated by the functions.$CaptureSingleWhen this variable is true, each occurence of unescaped "exactly one" wildcards (i.e. ? jokers or _ for SQL wildcards) are made capturing in the resulting regexp (they are be replaced by (.)). Otherwise, they are just replaced by .. Default is the latter. For jokers : 'a???b\??' is translated to 'a(.)(.)(.)b\?(.)' if $CaptureSingle is true 'a...b\?.' otherwise (default) For SQL wildcards : 'a___b\__' is translated to 'a(.)(.)(.)b\_(.)' if $CaptureSingle is true 'a...b\_.' otherwise (default)$CaptureAnyBy default this variable is false, and successions of unescaped "any" wildcards (i.e. * jokers or % for SQL wildcards) are replaced by one single .*. When it evalutes to true, those sequences of "any" wildcards are made into one capture, which is greedy ((.*)) for $CaptureAny > 0 and otherwise non-greedy ((.*?)). For jokers : 'a***b\**' is translated to 'a.*b\*.*' if $CaptureAny is false (default) 'a(.*)b\*(.*)' if $CaptureAny > 0 'a(.*?)b\*(.*?)' otherwise For SQL wildcards : 'a%%%b\%%' is translated to 'a.*b\%.*' if $CaptureAny is false (default) 'a(.*)b\%(.*)' if $CaptureAny > 0 'a(.*?)b\%(.*?)' otherwise$CaptureBracketsIf this variable is set to true, valid brackets constructs are made into ( | ) captures, and otherwise they are replaced by non-capturing alternations ((?: | )), which is the default. 'a{b\},\{c}' is translated to 'a(b\}|\{c)' if $CaptureBrackets is true 'a(?:b\}|\{c)' otherwise (default) Requirements: · Perl


Regexp::Wildcards Related Software