Is there a way to craft an expression that thwarts quotemeta()? We have an app that takes user data and applies a regex to it but before doing so it does quotemeta to the string. This is expected and desirable but, there are times I'd rather pass some metacharacters for instance I might want to pass a string like this:
\somedir\anotherdir\filename.\d{3}$
Once quotemeta is done with this it turns it into:
\\somedir\\anotherdir\\filename\.\\d\{3\}\$
What I'd like is to be able to bypass quotemeta's quoting.

I'd like the string to look like this:

\\somedir\\anotherdir\\filename\.\d{3}$
I had hoped perhaps \E prior to the desired meta would do the trick but quotemeta just escaped it. I didn't really expect that to work and I suppose it shouldn't but I'd still like to do something.

Does anyone have any suggestions?

TIA

Sweetblood


In reply to Escaping quotemeta() in regex by sweetblood

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.