From: Robert Klemme Date: 2008-03-07T23:49:38+09:00 Subject: Re: duplicating characters in a string 2008/3/6, Sebastian Hungerecker : > Robert Klemme wrote: > > You do not need groups: > > > > irb(main):003:0> "abc".gsub /./, '\\&\\&' > > => "aabbcc" > > > You do not need double backslashes either: > > >> "abc".gsub /./, '\&\&' > => "aabbcc" I know but I prefer to have them in because it's clearer what happens. Sometimes a single backslash works and sometimes not. IMHO some of the recurring discussions about the number of backslashes needed for replacement strings would not happen or be easier and shorter if there was a clear rule that \x always results in a non escaped string or error and in order to have a backslash in a string there must be two in the source. In other words, I would forbid '\1' and instead require '\\1'. Kind regards robert -- use.inject do |as, often| as.you_can - without end