Post Reply 
REPLACE Doesn't.
03-31-2017, 02:06 PM (This post was last modified: 03-31-2017 02:07 PM by toml_12953.)
Post: #4
RE: REPLACE Doesn't.
(03-31-2017 01:48 PM)Dieter Wrote:  
(03-31-2017 01:40 PM)toml_12953 Wrote:  
PHP Code:
for i from 1 to 4 do
   
replace(x,i,"0");
  
end

This probably is a very dumb answer, as I do not even have a Prime at hand to check it. But in all programming languages I know the "replace" string function does not replace the i–th character, instead it replaces one substring by another. Like this:

replace("apple pie", "apple", "orange") => "orange pie"

So the right approach may be something like a simple replace(x," ","9"). No for-loop required.

But again: probably this is a very stupid answer. You should know since you've got the manual. ;-)

Dieter

I tried this:

PHP Code:
x:="apple pie";
replace(x"apple""orange");
print(
x); 

"apple pie" prints. I'm really craving orange pie! Smile It seems to be a problem replacing characters in a variable.


Tom L

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
REPLACE Doesn't. - toml_12953 - 03-31-2017, 01:40 PM
RE: REPLACE Doesn't. - Dieter - 03-31-2017, 01:48 PM
RE: REPLACE Doesn't. - toml_12953 - 03-31-2017 02:06 PM
RE: REPLACE Doesn't. - Han - 03-31-2017, 02:10 PM
RE: REPLACE Doesn't. - toml_12953 - 03-31-2017, 02:15 PM
RE: REPLACE Doesn't. - Tim Wessman - 03-31-2017, 03:59 PM
RE: REPLACE Doesn't. - Dieter - 03-31-2017, 05:25 PM
RE: REPLACE Doesn't. - toml_12953 - 04-01-2017, 12:25 AM
RE: REPLACE Doesn't. - eried - 03-31-2017, 01:53 PM



User(s) browsing this thread: 1 Guest(s)