From: "Matthew, Graeme" Date: 2002-12-20T09:48:19+09:00 Subject: regex help please please ! This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C2A7C1.714F4A86 Content-Type: text/plain Hi All Please could someone assist as im now bald with a pile of hair around my chair ! How does one do greedy regex's in ruby ? in Perl / Python one has access to the /s or .DOTALL option but in ruby I cannot get a greedy effect. For example in Python to analyse a, yes im sorry visual basic file and tokenize it I can do the following: prog = re.compile(r""" (Private|Public)? #Look for Private or Public identifier but its optional \s* #Followed by any whitesoace (sub|function) #Followed by the word Sub or Function \s* #Followed by any whitesoace (.*?) #Followed by characters(name of token) \s* #Followed by whitespace, but its optional \( #Followed by an opening bracket - start of parameter enclosure (.*?) #Followed by a whole lot of text ie parameters :-) \) #Followed by a closing bracket (.*?) #Followed by a whole lot of text (the code) end\s+(sub|function) #Followed by the word End followed by Sub or Function """,re.DOTALL + re.IGNORECASE + re.VERBOSE) result = prog.findall(data) Thanks Graeme __ ********************************************** This e-mail and any attachments may be confidential or legally privileged. If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein. Please inform us of the erroneous delivery by return e-mail. Thank you for your cooperation. ********************************************** ec03/04 ------_=_NextPart_001_01C2A7C1.714F4A86 Content-Type: text/html Content-Transfer-Encoding: quoted-printable

Hi All

 

 

Please could someone assist as im now bald with a = pile of hair around my chair !

 

How does one do greedy regex's in ruby ? in Perl / = Python one has access to the /s or .DOTALL option but in ruby I cannot get a = greedy effect.

 

For example in Python to analyse a, yes im sorry = visual basic file and tokenize it I can do the following:

 

prog =3D = re.compile(r"""

         = ;   (Private|Public)?       #Look for Private = or Public identifier but its optional

         = ;   \s*            =          #Followed by any whitesoace

         = ;   (sub|function)          = #Followed by the word Sub or Function

         = ;   \s*           &nb= sp;         #Followed by any = whitesoace          &n= bsp;        

         = ;   (.*?)           &= nbsp;       #Followed by characters(name of token)           =        

         = ;   \s*           &nb= sp;         #Followed by whitespace, but its optional

         = ;   \(           &nbs= p;          #Followed by an opening bracket - start of parameter = enclosure

         = ;   (.*?)           &= nbsp;       #Followed by a whole lot of text ie parameters :-)

         = ;   \)           &nbs= p;          #Followed by a closing bracket

         = ;   (.*?)           &= nbsp;       #Followed by a whole lot of text (the code)

         = ;   end\s+(sub|function)    #Followed by the word End = followed by Sub or Function

         = ;   """,re.DOTALL + re.IGNORECASE + = re.VERBOSE)

        =

        result = =3D prog.findall(data)

 

 

 

Thanks

 

 

Graeme

 

 

 

__



**********************************************

=

This e-mail and any attachments may be = confidential or legally privileged.

If you received this message in error = or are not the intended recipient, you

should destroy the e-mail message and = any attachments or copies, and you are

prohibited from retaining, = distributing, disclosing or using any information

contained herein. Please inform us of = the erroneous delivery by return

e-mail.


Thank you for your = cooperation.

**********************************************

=

ec03/04


------_=_NextPart_001_01C2A7C1.714F4A86--