substitute multiple numbers


    Apr 04 2013 | 3:11 pm
    Is it possible to substitute multiple numbers?
    So if the combination of 5 6 is found substitute for 5?

    • Apr 04 2013 | 3:21 pm
      Found it!
      regexp (5\s6) @substitute 5
    • Apr 05 2013 | 8:58 am
      I am using the regexp to substitute numbers. However I am now facing some troubles with number with multiple digits.
      How do I address the numbers above 9???
    • Apr 05 2013 | 9:49 am
      Try this. You don't want to use character classes, instead use OR (|) matching.
      I'd prefer some kind of Max-native solution here, since using regular expressions like this seems messy, but I can't think of a better way.
      Best, Jeremy
    • Apr 05 2013 | 9:57 am
      the patch you wrote only seems to work with an input message of 3 (or 6 numbers)
      how can I alter it, that also the messages with two number work?
    • Apr 05 2013 | 10:00 am
      a combination of both does the trick:
    • Apr 05 2013 | 12:46 pm
      That doesn't really look right to me. In fact, your pattern will substitute more than 3 numbers: 5 7 8 11 12 becomes 3.
      You could try this: regexp (5|6|7|8|11)\s(6|7|8|11)((\s(6|7|8|11|12))?) @substitute 3 which uses the ? operator to make the 3rd group optional. But then it won't match "11 12", for instance, since it requires a 5, 6, 7, 8,or 11 at the front of the potential list followed by a 6, 7, 8 or 11. So that regexp will match a minimum of 2 and a maximum of 3 numbers in a row.
      Regular expressions can do nearly anything related to text processing, in fact, but like any other programming, you have to be really specific about the outcome you desire.
      Best, Jeremy