From: MonkeeSage Date: 2006-09-16T08:20:55+09:00 Subject: Re: No regex backreference with four backslashes gabriel.birke@gmail.com wrote: > I expected that when I remove the space from the first expression, that > my characters would get quoted. instead, the four backslashes get > interpreted as two escaped backslashes and the 1 as a literal > character. Can somebdoy shed some light on the how and why of this > case? Especially, why the solution with the five backslashes doesn't > yield double backlashes in the result string? In the replacement string, a backreference is a backslash followed by a number -- reference(\1) -- but a double-backslash is treated as a literal single backslash, so \\1 == literal(\1). So then, three backslashes and a number, \\\1 is equal to literal(\) reference(\1). Four means literal(\\1). Finally, five means literal(\\) reference(\1), and thus, since backslashes must be escaped to be seen as a single backslash in a string, you end up with the resulting string "1\\23\\45", meaning 1\23\45. Hope that makes sense. Regards, Jordan