Re: wildcard matching



On Jul 23, dan said:

i wasn't planning on using ? to match a single character, i figured that
would be getting too complicated. how would that be done anyway? i must say
my regex skills aren't very good :/

The ? metacharacter would map to Perl's . regex metacharacter.

   $temp1 =~ s{([^\w\s])}{
     if ($1 eq '*') { '.*' }
     else { "\\$1" }
   }eg;

If you wanted to support it here, you could end up doing

  $temp1 =~ s{([^\w\s])}{
    if ($1 eq '*') { '.*' }
    elsif ($1 eq '?') { '.' }
    else { "\\$1" }
  }eg;

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart
.