I'm looking to extract the expression that start with the CONSTANT, it could appear in any part and inside of any code, so i placed a couple of example to show you, the only "constant" part is the CONSTANT it self, the other part may vary between situation, let start:

#!/usr/bin/perl #this are a couple of example $_ = <<'REGEXP'; $one = CONSTANT . 'string' . $obj->new[0] . $variable . "string" . $ob +j->method("some".'thing'.$more); $some->method( CONSTANT . $obj->new[0] . 'string' . $obj->method("some".'thing'.$more +). $variable . "string" , "NOT INCLUDED" ); sub( CONSTANT . 'string' . $obj->new[0] . $variable . "string" . $obj->meth +od("some".'thing'.$more) ); REGEXP #let's magic begin! while (/ CONSTANT # begin the search with this string (?> #start looking but not return if fails "[^"]*" # catch every thing within double quotes | # or '[^']*' # catch every thing within single quotes | # or (\( # if its a parentheses (?> #start looking but not return if fails [^()]++ # catch every thing that is not a parentheses | # or (?1) # if its a parentheses make a recursion in it ) \))+ | #or same as above but looking square braket (\[ # if its a square braket (?> #start looking but not return if fails [^\[\]]++ # catch every thing that is not a square brak +et | # or (?2) # if its a square braket make a recursion in it ) \])+ | # or [a-zA-Z0-9_.\-\>\s\$]++ #looking only this string "." is po +int | # or (?R) # if those individual regexp fails, make a recursion, # only stop when all fails )* /xgo) { print "$&\n"; }

The problem with it, is the magic not begin, in fact, don't work at all

What i'm doing wrong?


In reply to RegExp, the magic not begin by perlmonkdr

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.