Regular Expressions in Max/MSP

Here’s a tutorial patch explaining how to use regular expressions with the [regexp] object in Max to parse text. It shows a few different techniques and includes examples of each. The code is below in JSON format so Max4 users can convert it and take a look too. Copy it into a new window, switch out of edit mode and click the titles to view them one by one. There are quite a few more complicated things you can ask regular expressions to do and if I ever find repeated uses for them I will try to add these topics to the file as well.

No problem Andrew, just good timing on my part for once! That regex will work just fine. I hope you find the tutorial useful. I didn’t renew the lightning bolts hosting so everything is being moved here for now. If you get stuck with anything else then you can always post on the Max/MSP forum or ask me about it right here.

Hi Luke!
First, thank you very much for the nice tutorial.
Sadly i still can figure out the simple regex:
I want to strip out a specific word from a string.
For example this word: TEST
Hello TEST luke, how are you? -> Hello luke, how are you?

Try copying this into a blank object box: regexp \\bTEST\\b @substitute %0. The percent zero bit is blank so it will replace every occurence of “TEST” with nothing, effectively removing it. It will also ignore words that contain the target string, for instance “DETEST” in the example above. I hope it helps.

My problem is about commas in filepath strings. I know it’s a reserved character in Max/Msp. I just want to escape them with a backslash or two, but that doesn’t seems to work… I must keep them, only escape them.
Everytime I get an error in Max : object box has comma or semicolon
Any idea ?
Thanks in advance