regexp??

Apr 27, 2009 at 8:57pm

regexp??

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. –
#43564
Apr 27, 2009 at 9:26pm

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

#156321
Apr 27, 2009 at 11:15pm

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

#156322
Apr 28, 2009 at 12:26am
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

#156323
Apr 28, 2009 at 3:13pm

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…

#156324

You must be logged in to reply to this topic.