On Sat 25-Nov-06 3:39pm -0600, Cameron Simpson wrote: > On 25Nov2006 15:30, Bill McCarthy <[EMAIL PROTECTED]> wrote: > | But the example I gave: > | echo substitute(a,'\','/','') > | actually works. The regex process appears to treat a single > | backslash as a special case - it treats it like a pair of > | backslashes. > > No, it treats it like a bare backslash - with no following character > it's not possible to treat it as a \x (for x something special like n, > etc), so rather than complain, it treats is as though it's not a > syntacticly special character. So it's "just a backslash".
Precisely. I meant to type "solo backslash." That would have been clearer. The regex parser treats a solo backslash (or as you pointed out later, a trailing unescaped backslash) as a special case. A solo backslash or a trailing unescaped backslash is treated the same way as though it were escaped (i.e. like a pair of backslashes). > | On the other hand, if I want to replace \b with /b then, > | using a literal, I clearly need that second backslash: > | > | echo substitute(a,'\\b','/b','') > > Yes. Again, the distinction is that the first backslash has a following > characters. You'll only see the behaviour in your first example when the > backslash is the last character in the rgexp. > > So you're really seeing here the regexp parser being forgiving instead > of strict. Yes. That's what I'm calling a "special case." I don't believe that special case is documented. Thanks for you comments. -- Best regards, Bill
