[Israel.pm] regex question

Oron Peled oron at actcom.co.il
Mon Jan 26 00:58:58 PST 2004

On Sunday 25 January 2004 15:48, Yuval Zaltz wrote:
> I need to parse a VB file that contains Functions and Subs. 

Using perl to fix VisualBasic... So ironic...

One strategy may be (not tested, you need to account for whitespace etc.):

	(Sub|Function)		# Start ($1)
	(.?*)			# Normal code ($2)
	(On Error (.*)\n)?	# Maybe 'On Error' ($3, $4)
	(.?*)			# Rest of code ($5)
	End			# Nothing to see here, move on
/$1$2 On Error FUBAR\n$5End/sgx;

This example rewrites the 'On Error' if it exists (note that $3, $4 are not

Oron Peled                             Voice/Fax: +972-4-8228492
oron at actcom.co.il                  http://www.actcom.co.il/~oron

The use of Basic cripples the mind; its use should, therefore, be
regarded as a criminal offence.  (With apologies to Edsger W. Dijkstra)

More information about the Perl mailing list