I have a file that I want to scan for matches of a regular expression.
The expression crosses multiple lines (/m), so I can’t use each_line.
I’ve been using scan, but I now need a match data object for each match
so I can get the position of the match. Is there a way to loop through
matches and get the match data for each match when all the data is in a
single string with multiple matches in it?

For arguments sake, here is the data:

public sub method1()
end sub

public sub method2(lots, of,
variables, over, many, lines)
end sub

public function method3() as string
end function

Here is the regular expression:

What is current returned by scan:

What I want:


On 11/23/06, Jeremy W. [email protected] wrote:

What I want:

something like this

‘aa’.scan(/a/) {|i| p $~ }

thanks, that worked great

Simon S. wrote:

Simon S.

Jeremy W.
Serval Systems Ltd.
Tel: 01342 331940
Fax: 01342 331950