Hello 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
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 .... ? Thanks

In reply to dos file masks and regular expressions by fluffyvoidwarrior

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.