change specific string within a message

R_Gol's icon

I have an income message as the following:
/p1/ear_r:tz

how can I change it for either: /p2/ear_r:tz or /p3/ear_r:tz

double_UG's icon

perhaps the is an easier way, but I am no regexpr sprinf expert

Max Patch
Copy patch and select New From Clipboard in Max.

Andy Maskell's icon

There are lots of possible ways to do this depending on how flexible you need to be. Two examples here include a very simple one if your new parameter doesn't vary much, and a more complex one where the parameter could be replaced with anything required:

Max Patch
Copy patch and select New From Clipboard in Max.

Andy Maskell's icon

By the way, sprintf is not necessarily the best means of performing text substitution as such - it is more for string formatting based on a wide range of formatting options. True, a sprintf formatting command can contain wildcards into which values can be inserted but not by replacement of delineated message elements, only by substitution of defined wildcards. However, it can be used as a reasonable replacement for combine in this case, thus:

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

If regex then without complications.

I find it interesting how unprecise many questions get asked here,
the simplest answer could have been
if /p1/ear_r:tz then /p2/ear_r:tz

that would replace it , or ?