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 pmperhaps the is an easier way, but I am no regexpr sprinf expert
- Jun 12 2022 | 4:02 pmThere 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:
- Jun 12 2022 | 5:50 pmBy 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:
- Jun 13 2022 | 11:17 amIf 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:tzthat would replace it , or ?