This is a case where you need to be precise with the terminology. In your first example, the first "/g iteration" (which I assume is what you mean by "match") sets \t to $regml(\n). \n = 1 in the first iteration, so \t is set to $regml(1) = "is". In the next iteration, \t is set to to $regml(2) = "Ga". Not sure if that's what you meant, but if you didn't, note that \1 and $regml(1) are quite different when /g comes into play. \1 always refers to the first capture in each iteration whereas $regml(1) refers to the first capture ever. \t is not set to \1, \2, \3 etc, it is set to $regml(1), $regml(2), $regml(3) etc.