PCRE stands for Perl Compatible Regular Expressions. It is a library that has been written to enable users of other languages to use the power of Perl's regular expressions. So, PCRE is just mimicking the Perl regular expressions, and, basically, anything you can do with PCRE can be done with Perl. In other words, if you really know how to do it in C with PCRE, then you should be able to do it very easily in Perl.

The issue we have here is that your problem is not very well defined, so that it is difficult to suggest a solution.

If I understand your issue correctly, you are not mastering the regexes that you are going to use, they are provided to you by an external source. If such is the case, then you can't do very much about it, it is the author of these regex that ought to provide you with the proper set of patterns.

Well, a general solution to this problem is probably out of reach, but I am also not saying that it can't be done. In theory at least, you might be able to parse the patterns supplied to you to build beginning-of-string regex sub-patterns provided those patterns supplied to you are relatively simple and very well defined, but that is not very easy and probably not a very robust solution, because you're probably bound to fail if the author of the patterns provided to you decides to start to be a bit too clever. OTOH, if you can define a very limited subset of authorized patterns, then it can probably be done. The fact that you seem to be willing to analyze directory paths is certainly essential to a possible definition of such simple patterns provided to you and therefore to a possible solution to your problem.

But you don't give us enough information for us to really be able to help you much further.


In reply to Re: Regex partial/leading match by Laurent_R
in thread Regex partial/leading match by raymorris

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.