I'd (probably) consider building and searching an index of ASTs (http://en.wikipedia.org/wiki/Abstract_syntax_tree).
Not only would it allow searching with regexp, but it could allow more sophisticated search queries like "Search all my Ruby code for blocks that rescue StandardError and are not followed by an ensure clause"