Blockland Forums > Modification Help

How to filter and replace a chat segment

Pages: << < (2/5) > >>

MegaScientifical:


--- Quote from: Julius The 1st on November 28, 2010, 10:57:25 AM ---Just wondering, but won't striReplace be non-case sensitive?

--- End quote ---

No, it's case sensitive. If it isn't, I have many problems with replacing "stuff" with "icecream" in the sentence "I stuffed myself" a few years ago when people cared for censors.

lilboarder32:

I don't believe striReplace exists. Only strReplace exists last time I checked.

Red_Guy:

try something like this:

%search = "World";
%change = "Changed";

%pos = strpos(%chatMsg, %search);
%newMessage = getSubstr(%chatMsg, 0, %pos) @ %change @ getSubstr(%chatMsg, %pos + strlen(%search), strlen(%chatMsg) );

DrenDran:


--- Quote from: Red_Guy on November 29, 2010, 01:11:57 AM ---try something like this:

%search = "World";
%change = "Changed";

%pos = strpos(%chatMsg, %search);
%newMessage = getSubstr(%chatMsg, 0, %pos) @ %change @ getSubstr(%chatMsg, %pos + strlen(%search), strlen(%chatMsg) );

--- End quote ---
Of course it needs to actually check if it needs to be replaced.
And it needs to keep looping until there isn't, or else it'll just replace the first occurrence.

MegaScientifical:


--- Quote from: DrenDran on November 29, 2010, 05:58:21 AM ---Of course it needs to actually check if it needs to be replaced.
And it needs to keep looping until there isn't, or else it'll just replace the first occurrence.

--- End quote ---

A problem is changing for case... same word, different case... Someone post the most efficient way to do a non-case-sensitive replace or else.

Pages: << < (2/5) > >>

Go to full version