I am trying to get the meat off the bones of some .bas, .frm, and .cls VB files. Using a filet_o_bas script, I have slurped the file in to a scalar. What I want to do now is strip off the declarations at the beginning and have just the Subs and Functions left so that I can digest them. Each may have a descriptive header before the Sub/Function declaration set off by dashed lines.

I have the following RegEx so far. The problem is that I do not want it to start capturing with a Sub or Function line that has "Lib" in it, since these are not functions that are written out. They are just aliases to other already existing library functions.

/ ( #Start capture ( #Start Sub descript header '\*{20,} #start '------ delimiter (\n'[^\n]*?)+\n #middle of header '\*{20,}\n #end '------ delimiter )? #End Sub header (optional) (Private\s|Public\s|Friend\s)? #Scope (optional) (Static\s)? #Static (optional) (Sub\s|Function\s) #Sub or Function (mandatory) [^\n]+ #more stuff on same line (?!\sLib\s) #but not if Lib on line .* #and the rest of the file ) #End capture /sx

For example, if I try it on a file having the following portion, I want it to start capturing on line 27. Instead, it starts capturing on line 24.

File header stuf... 22 Private Const strLen = 80 23 24 Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFil +eA" _ 25 (ByVal lpFileName as String) as Long 26 27 '-------------------------------------------------------- 28 ' Purpose: Donuts 29 ' Author: not me 30 ' Date: yesterday 31 '-------------------------------------------------------- 32 Private Sub DrainBattery(Byval sPercentage as Single) Code stuff...

In reply to lookahead, lookbehind, ... I'm lost by ExReg

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.