Hi,
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
It does the same with 7.2, 7.4
/ David
Eh, "." is a string literal containing a single dot. "\b" is a string literal containing a single backspace. The first is printed as ".", the second is printed as "\b". Replaceing a dot with a dot of course does nothing.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-09-09 14:43: Subject: Bug in replace
Hi,
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
It does the same with 7.2, 7.4
/ David
/ Brevbäraren
Eh, "." is a string literal containing a single dot.
Shouldn't "\." be a string literal containing one backslash and a dot?
Eh, "." is a string literal containing a single dot.
Shouldn't "\." be a string literal containing one backslash and a dot?
Yes?
"." : a string literal containing a single dot. "." : also a string literal containing a single dot. "\." : a string literal containing one backslash and one dot
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-09-09 14:51: Subject: Re: Bug in replace
Eh, "." is a string literal containing a single dot.
Shouldn't "\." be a string literal containing one backslash and a dot?
-- Bertrand LUPART Linkeo.com - R&D | http://www.linkeo.com/ +33 1 72 71 71 82 | 17, rue de la Banque - F75002 Paris Systèmes de gestion d'email entrant | Email management systems
/ Brevbäraren
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
And just in case people would wonder:
replace(s, ".", "\.");
(4) Result: "foo\.bar\.com"
/ David
Are you perhaps fooled by the fact that hilfe writes valid pike-strings?
Try write( replace( s, "a", "\b" ) + "\n" )
/ Per Hedbor ()
Previous text:
2004-09-09 14:46: Subject: Re: Bug in replace
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
And just in case people would wonder:
replace(s, ".", "\.");
(4) Result: "foo\.bar\.com"
/ David
/ Brevbäraren
Ah yes indeed, I understand now, thank you all.
/ David
Per Hedbor () @ Pike (-) developers forum wrote:
Are you perhaps fooled by the fact that hilfe writes valid pike-strings?
Try write( replace( s, "a", "\b" ) + "\n" )
/ Per Hedbor ()
Previous text:
2004-09-09 14:46: Subject: Re: Bug in replace
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
And just in case people would wonder:
replace(s, ".", "\.");
(4) Result: "foo\.bar\.com"
/ David
/ Brevbäraren
Replace doesn't seem to like . :
Replace seems not the only one affected:
$ pike7.6 Pike v7.6 release 11 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; array parts = s/"."; s=parts*".";
(1) Result: "foo.bar.com"
(same in 7.2)
Does anyone actually read the answers we give? "." IS THE SAME AS ".". Of course you get the same thing back when you implode (*) with the same string as you explode (/) on.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-09-09 14:50: Subject: Re: Bug in replace
Replace doesn't seem to like . :
Replace seems not the only one affected:
$ pike7.6 Pike v7.6 release 11 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; array parts = s/"."; s=parts*".";
(1) Result: "foo.bar.com"
(same in 7.2)
-- Bertrand LUPART Linkeo.com - R&D | http://www.linkeo.com/ +33 1 72 71 71 82 | 17, rue de la Banque - F75002 Paris Systèmes de gestion d'email entrant | Email management systems
/ Brevbäraren
Does anyone actually read the answers we give?
Answers have been given while asking the second question.
"." IS THE SAME AS ".". Of course you get the same thing back when you implode (*) with the same string as you explode (/) on.
Sure. I was fooled by hilfe too.
what has not been asked yet is:
why is there an escape for .? they are not special characters in strings.
for a moment i thought this could be to help simplify arguments to regexps, but that can't be as the escape will be replaced before the regexp handler sees it.
so when was . introduced and to what end?
greetings, martin.
It's not an escape for ".", it's a general escape. Most escape systems work that way so that you can escape anything if you are unsure what chars it's needed for.
/ Peter Bortas
Previous text:
2004-09-09 16:45: Subject: Re: Bug in replace
what has not been asked yet is:
why is there an escape for .? they are not special characters in strings.
for a moment i thought this could be to help simplify arguments to regexps, but that can't be as the escape will be replaced before the regexp handler sees it.
so when was . introduced and to what end?
greetings, martin.
/ Brevbäraren
(And no, that is not perticularly helpful in this case.)
/ Peter Bortas
Previous text:
2004-09-09 16:48: Subject: Re: Bug in replace
It's not an escape for ".", it's a general escape. Most escape systems work that way so that you can escape anything if you are unsure what chars it's needed for.
/ Peter Bortas
What is rather nice though is the notion that \ _always_ acts as an escape character, regardless of what character follows it. If this was not the case, \x would sometimes be one character and sometimes two, depending on what x is. The way it is now is more consistent.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-09-09 16:49: Subject: Re: Bug in replace
(And no, that is not perticularly helpful in this case.)
/ Peter Bortas
right, it also forces that if you want a \ you must always escape it, regardless of the character that follows.
otherwise changing a following character could result in the \ mysterisously disappering.
greetings, martin.
More like "sometimes one character and sometimes a compilation error".
/ Martin Nilsson (DivX Networks)
Previous text:
2004-09-09 17:05: Subject: Re: Bug in replace
What is rather nice though is the notion that \ _always_ acts as an escape character, regardless of what character follows it. If this was not the case, \x would sometimes be one character and sometimes two, depending on what x is. The way it is now is more consistent.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Why? When do you need write "\m"? But not giving an error you prevent future assignments of meaning to it.
/ Martin Nilsson (DivX Networks)
Previous text:
2004-10-07 07:59: Subject: Re: Bug in replace
I would prefer a warning and an optional compiler error.
/ Marcus Agehall (PacketFront)
That's a good point. Nevertheless, I'm in favour of a relaxed compiler with optional ADA-faschist-like checks.
/ Marcus Agehall (PacketFront)
Previous text:
2004-10-07 14:50: Subject: Re: Bug in replace
Why? When do you need write "\m"? But not giving an error you prevent future assignments of meaning to it.
/ Martin Nilsson (DivX Networks)
you are right, i didn't even consider that. if it works with any character then it makes sense too. thanks.
greetings, martin.
To my knowledge . is not a valid escape anywhere.
If you really want to replace the character . with ., you should write replace( s, ".", "\." )
/ Per Hedbor ()
Previous text:
2004-09-09 14:43: Subject: Bug in replace
Hi,
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
It does the same with 7.2, 7.4
/ David
/ Brevbäraren
Replace doesn't seem to like . :
It seems you're confused; \ is the string escape character. replace will never see the \ in the string ".", since it is equvivalent to the string ".".
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
In the last case you're actually specifying a valid -escape (BEL).
It does the same with 7.2, 7.4
As it should.
/ Henrik Grubbström (Lysator)
Previous text:
2004-09-09 14:43: Subject: Bug in replace
Hi,
Replace doesn't seem to like . :
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
It does the same with 7.2, 7.4
/ David
/ Brevbäraren
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
In the last case you're actually specifying a valid -escape (BEL).
\b is not BEL. \a is BEL. \b is BS.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2004-09-09 14:47: Subject: Bug in replace
Replace doesn't seem to like . :
It seems you're confused; \ is the string escape character. replace will never see the \ in the string ".", since it is equvivalent to the string ".".
string s = Pike v7.6 release 13 running Hilfe v3.5 (Incremental Pike Frontend)
string s = "foo.bar.com"; replace(s, ".", ".");
(1) Result: "foo.bar.com"
replace(s, "a", ".");
(2) Result: "foo.b.r.com"
replace(s, "a", "\b");
(3) Result: "foo.b\br.com"
In the last case you're actually specifying a valid -escape (BEL).
It does the same with 7.2, 7.4
As it should.
/ Henrik Grubbström (Lysator)
pike-devel@lists.lysator.liu.se