change specific string within a message


    Jun 12 2022 | 11:41 am
    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

    • Jun 12 2022 | 12:51 pm
      perhaps the is an easier way, but I am no regexpr sprinf expert
      Max Patcher
      In Max, select New From Clipboard.
    • Jun 12 2022 | 4:02 pm
      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 Patcher
      In Max, select New From Clipboard.
    • Jun 12 2022 | 5:50 pm
      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 Patcher
      In Max, select New From Clipboard.
    • Jun 13 2022 | 11:17 am
      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 ?