From: Benjohn Barnes Date: 2006-12-15T08:34:41+09:00 Subject: Re: Restricted capture in Regexp On 13 Dec 2006, at 17:35, Paul Lutus wrote: > Is this what you mean? Can you extrapolate this way of approaching the > problem to solve your own? I was able to. I had not understood that scan and gsub work differently when capturing takes place. Scan seems to have more sensible behaviour. I would like gsub's block or second parameter to provide an array, and for this to replace the captured parts of the regexp, so: "axb".gsub(/(.)x(.)/, ['A', 'B']) would return: "AxB" gsub doesn't behave like this, but I imagine it would be possible to build a gsub like function that did. :) It would probably need to inspect the regular expression given to it with a regular expression. Thanks everyone, Benjohn