>>>>> "A" == =?iso-8859-1?Q?Aleksi Niemel=E4?= <iso-8859-1> writes: A> The statement of "last successful match" implicates that this is not the A> behaviour and all 'p $1' statements on my example should print "matches A> bar". Unlike perl, ruby don't have the notion of "last successful match" A> def foo(str) You must know that $~ is a *local* variable A> /(foo)/.match(str) A> bar(str) A> p $1 # the *latest* successful match has happened at bar A> end When you call a def, the first 2 local variables are $_ and $~ Guy Decoux