You're probably not going to like this, but it's going to be more trouble than you're probably willing to go through to deal with this solely with regexps. Basically, unless you use fancy trickery like (?{code}) you can't express enough state in a regular expression to deal with arbitrary Javascript. This is the same reason that you can't handle arbitrary (X|HT|SG)ML solely with regexen. If I recalled more than vague snippets I could probably back this up with some mumbo-jumbo about LA(1) and LALR(1) grammars and the like.

To do things `right', you'd basically need to write a Javascript parser (or at least a tokenizer) that knows enough about Javascript syntax that it can keep enough state to tell the difference between quotes occurring inside JS regexen and those happening inside of double quoted strings.


In reply to Re: Extracting C Style Comments Revised (JavaScript) by Fletch
in thread Extracting C Style Comments Revised (JavaScript) by Incognito

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.