From: Ammar Ali Date: 2010-11-19T22:50:40+09:00 Subject: Re: Multi-line regular expression match question On Fri, Nov 19, 2010 at 2:42 PM, Guillermo Riojas wrote: > I need to match anything that is enclosed in between "|-:" and "-|" > So far i've got "/^\{\|-:$.*^-\|$/m" , this one is greedy, returning the > complete set, instead of each match, i just haven't figure out how to > make it reluctant enough to return one by one. If you're using ruby 1.9 you can do us that, *? is the reluctant version of *: /^\|-:$.*?^-\|$/m Note that I removed the '\{' from your original pattern. It is not needed in this case. If you're on 1.8, one possibility is: /^\|-:$(?m:.*?)(?=^-\|)^-\|$/ But there are other, probably more efficient, ways to do it as well. > And finally, any good regular expressions book ?? =) Jeffrey Friedl's Mastering Regular Expressions is an excellent read and covers regular expressions inside and out, literally. Here's the amazon link: http://oreilly.com/catalog/9780596528126 HTH, Ammar