Regexp question

    May 25 2012 | 11:30 pm
    hey all - say i have a string of numbers: 32 32 32 32 00 x y z 88 56 46
    and i want to grab just x,y and z from that string? the x y z variables change, while the other numbers remain constant, so I'd like to strip those away and be left with x,y and z
    how might i set that up using regexp - and is that the best way?
    I am assuming it has to do with the backreference outlet.

    • May 26 2012 | 12:48 am
      Are x y z numbers too?
      You could certainly do it with regexp, but there might be easier ways. Here are two random methods with zl.slice and unjoin:
    • May 26 2012 | 12:50 am
      Since your input seems a list of numbers I would use simple list operations.
    • May 26 2012 | 2:28 pm
      Thanks for the replies - mighty kind.
      I should have been a bit more specific - that string can exist in a march larger string of numbers and yes the variables are all numbers.
      I am sending HUI information from Pro Tools to max and want to pull the individual channels names from the stream of numbers that come in. I have identified them manually but would like to learn how to have max pull them out of the stream.
      so the patch would need to be able to extract a specific pattern (or actually up to 8 specific patterns) from a long stream of numbers.
    • May 26 2012 | 4:24 pm
      Have a look at [zl stream].
    • May 26 2012 | 5:21 pm
      @broc - thanks - i will check that out. is there a way to tell zl there are variables in the stream?
      for example if i feed zl.filter 240 0 0 102 5 0 16 0 VXYZ 247 where VXYZ are the variables (always numbers) can i represent that in the message zl.filter is meant to be filtering?
      Basically telling it - grab 240 0 0 102 5 0 16 0 (whatever 4 numbers are here) 247
    • May 26 2012 | 6:50 pm
      You can use zl.filter only if the variables VXYZ are always different from the given numbers.
    • May 26 2012 | 6:55 pm
      Thanks for the reply - obliged!
      The catch is they are not - pro tools is spitting out all kinds of text (via sysex) and i just want to isolate specific strings which are the channel names. So, unfortunately. sometimes the variables in VXYZ will be numbers that appear elsewhere in the stream, however, it will always be exactly 4 variable and always be preceded by the same sequence and followed by the same sequence.
    • May 26 2012 | 7:16 pm
      Why don't you use [sysexin] for this? Then you could apply (for the fixed number of bytes), and zl.slice as mentioned earlier.
    • May 26 2012 | 8:40 pm
      hi - sorry - feeling a bit thick on this - i think i am missing something basic.
      I am indeed using sysexin for getting the data
      What i don't understand is how to make the object filter out the string i want.
      a wild guess:
    • May 26 2012 | 10:13 pm needs the length of the sysex message as argument, ie. 13 in your case.
    • May 27 2012 | 2:51 pm
      gotcha - thanks for your help on this!
      I understand how that works in your example - but that is assuming that every sysex message coming from protools is in groups of 13 - right?
      Problem is that they are many messages coming in various lengths.
      When i use 13 - i can see attached file in the max window:
      As you can see each group of 13 isn't always complete as it may include numbers from the previous or next group of 13.
      Wondering if my original plan of figuring out how to have Max identify a particular string and grab it from an incoming stream would be the best option - is this possible?
      so that it would see 240 0 0 102 5 0 16 0 V X Y Z 247 and extract that.
      then i could use z slice to be left with v x y z
    • May 27 2012 | 2:59 pm
      possible to have zl.lookup work with a group of numbers instead of just single numbers?
    • May 27 2012 | 7:10 pm
      If the message length is variable you can trigger the group with the end symbol (247).
    • May 27 2012 | 7:36 pm
      Thanks - literally just solved it a slightly different way.
      appreciate the help!!!
    • May 28 2012 | 5:37 am
      If you want to use regexp, this might work for you:
    • May 28 2012 | 3:30 pm
      Thanks Ben! I figured there must have been a way like that.