On Thu, Aug 21, 2003 at 03:02:22AM +0900, Matt Lawrence wrote: > I've often wondered if there was a good alternative to using $1, $2, $3, > etc. to pull stuff out of a string that has been matched with a regular > expression. Ideas? yes. the match method returns a MatchData object which stores this information, as well as the text before, and the text after the match. An example from the pickaxe book: m = /(.)(.)(\d+)(\d)/.match("THX1138.") m[0] "HX1138" m[1, 2] ["H", "X"] m[1..3] ["H", "X", "113"] m[-3, 2] ["X", "113"] other methods of the MatchData object are post_match, pre_match, length, etc ... you could see the book itself for details :) (http://www.rubycentral.com/book/ref_c_matchdata.html) ... but how do you get around the other dollar-variables? like $<, , $_ and $! ... i really hate global variables ... i think they are unelegant. is there an object oriented way to access them? bye RvB (Rene van Bevern) <rvb / rvb.dyndns.org>