Try using 

content.scan(/(Private|Public)?\s*(sub|function)\s*(.*?)\s*\((.*?)\)
do |match|
<do something with 'match'>
end

The =~ operator WILL always start at the beginning.

Jason

--- "Matthew, Graeme" <Graeme.Matthew / mercer.com>
wrote:
> Hi all I have a wee problem here
> 
>  
> 
>  
> 
> I have a variable that contains the contents of an
> entire file (actually a
> visual basic bas file), I am currently building a
> doc tool in ruby to
> document some systems
> 
>  
> 
> My problem is the regex is not matching all
> occurrences on a while loop, it
> goes into a continious loop, im thinking it is
> resetting the starting
> position on each match
> 
>  
> 
> Eg:
> 
>  
> 
> while  content =~
>
/(Private|Public)?\s*(sub|function)\s*(.*?)\s*\((.*?)\)(.*?)end\s+(sub|funct
> ion)/mi
> 
>                                     p "#$3\n"
> 
> end
> 
>  
> 
> content would be something like
> 
>  
> 
>  
> 
> private function mbGetStatus(Byref rlItems as long)
> as Boolean
> 
>  
> 
>  
> 
> end function
> 
>  
> 
>  
> 
> public function gbGetName(Byref rlId as long) as
> string
> 
>  
> 
>  
> 
> end function
> 
>  
> 
> any ideas ?
> 
>  
> 
> Cheers
> 
>  
> 
>