From: Stephen White Date: 2000-08-27T04:07:18+09:00 Subject: [ruby-talk:4592] Getting list of regexp matches I'm sure looking forwards to buying the book. :) I don't quite understand the concept of iterators. Let's say I have an array of regexp's containing keywords, like: keywords = [ /int/, /float/, /double/ ] then I have a file in variable, like: a = File.new("freddie.c").read(nil) I can understand how to use iterators to go through the keywords array, but not how to get an array of matches. What I'd like out of this is a list of matches, like: [ "int", [ 56, 78, 128 ], "float", [ 90, 400 ], "double", [ 200, 250 } } Is Ruby capable of iterating through regexp matches, or do I have to restart regexp for every match, which is wasteful of resources? Thanks... -- steve@deaf.org