Forums > MaxMSP

regexp??


MIB
April 27, 2009 | 8:57 pm

regexp always gives me headaches…

So I have filenames like C#3 or G#4. I would like to convert this into a 3 element list so I can do comparisons. For this I thought I could use [regexp \w]. Unfortunately, that gets rid of the #. Is there a quick workaround? Am I misunderstanding?

Thanks

– Pasted Max Patch, click to expand. –

April 27, 2009 | 9:26 pm

The problem is that # isn’t a word character and won’t be recognised by \w. Try using [regexp .] instead which will output any character. Or something like [regexp (.) @substitute "%1 "] and see what comes out of the first outlet. This basically puts a space after every character in the input string. It should do what you want but seeing as I don’t know exaclty what sort of messages you’re sending I can’t tell if you might run into problems using this approach.

lh



MIB
April 27, 2009 | 11:15 pm

that was exactly what I was looking for. Thanks!
one of these days I really have to learn how to use regexp properly.


April 28, 2009 | 12:26 am
MIB wrote on Mon, 27 April 2009 13:57
regexp always gives me headaches…

So I have filenames like C#3 or G#4. I would like to convert this into a 3 element list so I can do comparisons.

There’s a good example of how to do this, by John MacCallum, in the CNMAT MMJ Depot. Find the whole thing here:

http://cnmat.berkeley.edu/downloads/

Then find pitch2midi.maxhelp in /CNMAT_MMJ-Depot/modules/MIDI/ Just what you want.

mz


April 28, 2009 | 3:13 pm

I am trapped, and can’t access the CNMAT Site. I registered probably long time ago, but the e-mail address back than has vanished. I could of course create a new account as Donald Duck, but I’d prefer my real name…


Viewing 5 posts - 1 through 5 (of 5 total)