From: david karapetyan Date: 2007-08-06T14:51:58+09:00 Subject: Re: accessing all matches using regex ------=_Part_112851_25273185.1186379521913 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline look up gsub! for the String class. you can write some_string.gsub(/href=\"([^\"]+)\"/) do |match| ## do stuff with match end i'm pretty sure the above code will work for what you are trying to do. On 8/5/07, Spike Grobstein wrote: > > Hey all > > so, I primarily use PERL for creating shell scripts but I'm trying to > learn ruby since it feels like it could do more of what I want with > cleaner code. I especially like the way it has regex built right in. > > I'm running into an issue though, because in perl, I can do this: > > while (/href=\"([^\"]+)\"/) { > ## do stuff... > } > > I use this simple regex because it's based around what I use this style > for the most. > > I can't figure out how to that in ruby. how can I iterate over all > matches in a string? I could split the lines, but sometimes there may be > two or more matches on a single line. > > is there a nice, clean, ruby way to do this? > > Thanks! > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_112851_25273185.1186379521913--