parsing OSC messages...

    Nov 12 2006 | 11:36 am
    I am a Lemur user and I am trying to parse messages that are created by default (based upon my object creation) by the Jazzmutuant Lemur/JazzEditor, in Max. These messages come out as a long word such as "/Lem40j/Press_0/x 0" or "/Lem40j/Press_12/x 3" ... which are mixed with words, decimals, and other symbols...
    I saw the post on using the object 'regexp' to parse out things from entire words, but am not able to understand all the messages, etc, in the reference manual for this object in order to apply it to my specific application. I specifically would like to be able to change "/" or "_" symbols to spaces and then be able to further unpack the symbol into individual digits contained within...
    Here is an example of what I would like to parse:
    from message:
    "/Lem40j/Press_0/x 0"
    "40 0 0" or at least "Lem 40 j Press 0 x 0"
    "/Lem40j/Press_12/x 3"
    "40 12 3" or at least "Lem 40 j Press 12 x 3"
    Is this possible with 'regexp' or maybe another object?
    Really, if I could just change a "/" to a "space", my problems could be mostly solved.
    But also, to know how to change any other basic digit, letter, or series of letters to "spaces" (to create a list!), would be a wonderful thing to know.
    It seems that I basically need the opposite of what the 'tosymbol' object does... instead of taking a list and creating a single symbol with "/"s instead of spaces using the message:"separator /" ... I want to take a symbol with "/"s and replace those "/"s with "space"s and create a list.
    As a complimentry object, one would think that the 'fromsymbol' object would do this... but it doesn't!
    Thank for any help!

    • Nov 12 2006 | 12:10 pm
      Hey, I think this is what you're looking for:
    • Nov 12 2006 | 2:06 pm
      I think you're looking for the [OSC-route] external from CNMAT.
      it's made for parsing the URL-style paths in the OpenSoundControl
      "/Lem40j/Press_12/x 3" would be parsed by: [OSC-route Lem40j] -> [OSC-
      route Press_12] -> [OSC-route x]
      to replace any one character by another in a symbol i'd use regexp
      like so:
      [regexp @re ([/]*) @substitute " "]
      or if all you want is to slice one symbol into substrings at a
      specific character use my [strtok] external from the standard C
      functions. ->
      full patch see below
    • Nov 12 2006 | 6:36 pm
      Thanks so much for your replies.
      That definitely seems to cover all that I want/need to do. Your [strtok] object especially is wonderful... Very simple (especially compared to regexp!) and intuitive. Exactly what I was hoping existed. Thank you very much!