in reply to Map file-glob-style patterns to SQL "LIKE" expressions, with escaping

I'm confused on this. It looks like you are putting in characters for wildcard which won't be accepted by, for instance, MySQL, which only has % and _ as wildcards, per the docs

Replies are listed 'Best First'.
Re^2: Map file-glob-style patterns to SQL "LIKE" expressions, with escaping
by graff (Chancellor) on Apr 01, 2005 at 03:21 UTC
    If the original file-glob string is something like:
    what\?_not\*.%
    a file-glob sees a backslash escape before the "?" and "*" (to match a literal question mark and asterisk), and treats "_" and "%" as normal (literal) characters.

    For conversion to an sql "like" pattern, the "\" must be removed from in front of "?" and "*" (because these characters don't need to be escaped now) and must be added in front of each "_" and "%" (to keep them literal, as they were in the file-glob).

Re^2: Map file-glob-style patterns to SQL "LIKE" expressions, with escaping
by merlyn (Sage) on Apr 01, 2005 at 03:11 UTC
    It maps * to % and ? to _, so I can write "??a*", and get any three-or-more character value where the 3rd character is "a". It's mapping to SQL. I'm not putting anything in there that isn't understood in standard SQL92.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.