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".

| 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.
-- 
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/

I worry about my child and the Internet all the time, even though she's
too young to have logged on yet. Here's what I worry about. I worry
that 10 or 15 years from now, she will come to me and say 'Daddy, where
were you when they took freedom of the press away from the Internet?'
        - Mike Godwin

Reply via email to