From: Brett Parker Sent: 03 February 2005 14:00 On Thu, Feb 03, 2005 at 10:39:21AM -0000, Keith Watson wrote:
I have a stack of JavaScript files from which I want to
extract the function definition lines and the following comment block for documentation purposes,
...[lots deleted]...
I'd probably go the perl route, but that's because I can't write awk ;)
yeah, not my favourite scripting language either, but I know it has it's uses (he said hastily :o) )
If I get a chance later on tonight, I'll throw something out that should work.
gracias, amigo
I assume that the comments are always straight after the function definition?
yes
I'd have expected it to be /** at the top of the comment for Java, but I suppose as this is JavaScript I'm not surprised that it's not.
ditto, but that's the way whoever did it coded them. It's quite readable though, so I can see why it was done that way.
It should be relatively simple... parse the file for the function keyword at the beginning of a line, then select everything up to the first occurrence of */, should be relatively simple.
that's why I wondered if it could be done with a suitable cunning regular expression and egrep.
Any regex guru's fancy a crack at this? :o)
Keith ____________ CONNOISSEUR, n. - A specialist who knows everything about something and nothing about anything else (q.v. EXPERT). - Ambrose Bierce - The Devil's Dictionary