Ok, I have a text file with the following in it:

\t\tmy($page)=&create_page(isitvalid("templatefile.html"),\%replace,\% +lists,@unhide);

NOTE: the \t's represent actual tabs in the file

I also have a script with the following regex

s/^\W* # we may have some white space at start of line my\W*? # all variable will use my \(? # variable may or may not be list \W*? # some people space out the parens and some don't \$page # assuming for now that page is always the variable \W*? # more possible space around parenthesis \)? # variable may or may not be a list \W*? # whitespce is optional = # we have to assign the variable \W*? # more optional whitespace \&? # function may or may not be explicitly contexted create_page\W*? # the name of the funciton followed by optional +space \( # parenthesis begins the parameterlist \W*? # we might have whitespace before first parameter ([^,]*?) # BROKEN: this should collect everything up to the +next comma in variable number 1 \W*? # this shouldn't be necessary since whitespace should h +ave been slurped on previous line but this shouldn't hurt either , # Got to have the separator \W*? # more optional whitespace ([^,]*?) # NOT BROKEN: this grabs everything up to the secon +d comma (of course we don't have parens and dblquotes in second param \W*? # this shouldn't be necessary since whitespace should h +ave been slurped on previous line , # Got to have the separator \W*? # more optional whitespace ([^,]*?) # NOT BROKEN: third one gets gotten fine as well \W*? # again the unnecessary whitespace collector , # Again the seperator \W*? # Again the optional whitespace ([^)]*?) # NOT BROKEN: heres our final collection point \W*? # Again with the unnecessary whitespace \) # our parameter list has come to a close \W*? # whitespace might seperate from closing punctionation thou +gh it seems unlikely ; # closing punctuation ends the statement the replace doesn't m +atter for the question /my \$renderer = new HRsmart::Lightning::Render ( template => $1 +,\n\t\tloops => $3,\n\t\treplace => $2,\n\t\tfinals => $4 );\n\$rende +rer->customize_header\( \$company_id \);\nmy \$page = \$renderer->ren +der;\n\$page =~ s\/~%.{0,20}%~\/\/g;\n/gx;

As you can see I'm trying to replace the old functional way of doing things with a new semi-oo way.

The problem is, instead of getting 'isitvalid("templatefile.html")' for $1 which is what I was expecting, it is cutting off before the second double quote, so I get 'isitvalid("templatefile.html'

Anyone can point me in the right direction?

BTW there's no chance of spaces between the doublequotes, so that's not an issue.

UPDATED: Under-commented code replaced with Over-commented code


In reply to replacing code with regex by raflach

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.