in reply to Re: lookahead, lookbehind, ... I'm lost
in thread lookahead, lookbehind, ... I'm lost

Thanks so much for your quick reply. Sorry it took me so long to get back. I had made a few mistakes, and it doesn't take much to screw up a RegEx. I put in a bit more detail, like capturing the fucntion name and parameters. A bit more screaming at it until a slash turned into a backslash, and it finally worked.

use strict; undef $/; while (<DATA>) { print; / ( #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) (\w+) #Sub name ( #Start Params \( #Left paren ([^\)])* #Optional params inside \) #Right paren )? #End Params (optional) \s+ #Space ((?!Lib\s)) #no Lib on line ([^\n]+) #more stuff on same line unless "Lib +" (.*) #and the rest of the file ) #End capture /sx; }; __DATA__ Private thingy as String Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" '----------------------------------------------------------- ' This is a header '----------------------------------------------------------- Private Function foo(byVal x as Long, byVal y as String) as Integer

It correctly ignores the first three lines and starts capturing at the '-----------. Thanks!