fluffyvoidwarrior has asked for the wisdom of the Perl Monks concerning the following question:
I can get my users to handle wildcards but regexp... no chance. Any suggestions are as always appreciated and perhaps wiser eyes will say that I'm tackling this the wrong way .... ? ThanksHello All, Any ideas how to recreate a dos wildcard filemask of the typ +e "help*.txt" as a string for insertion in a pattern match. At the + moment I'm trying to write a subroutine that returns an escaped stri +ng which I then insert in my m// ... ie $myregex = &my_regex_generator("help*.txt"); if( $mystring =~ /$myregex/i){do stuff.... at the moment I've got - sub gen_convert_wildcards_to_regexp{ my $wildcardstring = $_[0]; my $regex_string = $wildcardstring; $regex_string =~ s/\./\\\./gi; #escape the dots $regex_string =~ s/\*/\\*/gi; #escape the $regex_string = $regex_string . "\\b\$"; return $regex_string; } Which is pretty crap and fails with the * wildcard
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dos file masks and regular expressions
by reasonablekeith (Deacon) on Jan 04, 2006 at 11:24 UTC | |
by fluffyvoidwarrior (Monk) on Jan 04, 2006 at 12:00 UTC | |
|
Re: dos file masks and regular expressions
by pKai (Priest) on Jan 04, 2006 at 11:58 UTC | |
by rinceWind (Monsignor) on Jan 04, 2006 at 12:24 UTC | |
by fluffyvoidwarrior (Monk) on Jan 04, 2006 at 12:10 UTC | |
|
Re: dos file masks and regular expressions
by rinceWind (Monsignor) on Jan 04, 2006 at 12:34 UTC | |
by fluffyvoidwarrior (Monk) on Jan 04, 2006 at 13:01 UTC | |
|
Re: dos file masks and regular expressions
by Anonymous Monk on Dec 13, 2017 at 13:10 UTC |