The real reason I started this blog – to publish little snippets of code! I owe my sensei for help with this one.
class Regexp # Matches ALL occurrences of a regular expression in a string. # Returns an array of the matches as strings. # The regular expression must explicitly use groupings [ like (capturethis) ] # to capture matching strings. def matchAll( string ) matchArray = ; work_str = string; while (m = self.match( work_str ) ) matchArray << m.captures; work_str = m.post_match; end return matchArray; end end