Replace message at position x to y

flocked's icon

Hi,
I have a message. e.g.:
"I have a nice cat"

Now I want to replace a part of the message from x to y. - e.g: 10-15:
"I have a nice hat"

How can I do that? I can't find any objects that are related to messages or the string length.

Thanks!

laonikoss's icon

Take a look at [regexp], [sprintf] and [combine].

flocked's icon

Thanks. Are you sure that regexp works? I can only see examples of regexp, where the message structure is known in advance.

I don't know the structure of the message, because it is more or less random (the user can enter a message). - I only know the position, where I want to replace and how much i want to replace.

flocked's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Got it! - without regex and sprintf :)

laonikoss's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I'm not an expert with [regexp] and I'm sure there's a more elegant solution than this one, but here's a little hack that might do the job using [zl] and [atoi]:

flocked's icon

I found the solution already and your solution isn't exactly what I wanted. But thanks! :)