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?
----------begin_max5_patcher---------- 373.3oc2U9saBCBEF+Z5SAgcamoz+oY2s3R1CwlYAaYJKsPSAicy369Jm15T m5pyabqIEBG93vG+JPW4fHSUUbMAeG9ILBsxAgfP1.n11HRNqJIioAYjbtVy lwItM8Y3UFH9XbPWrBlIYtPN6kRdhoI29dwC7bwATOaUDTRqCgmzNFQJjE0z 2tcTWdTKLYbi48BdSRHjMxeUIMRVNzA49RAKqaPxE4BY8v.25ukbs3CPNXgM ZalCPL0Fbsiisv8BowiS8OEMFNxB.+fP.J9ChNNMh+GPiGhOELBi5MLBuHXT Tx0bogYDJ4QMfWawl7ccfvw2bxiWMmq5ECC9CsgRxWVa4uAiR9LdUA945mk8 fJCo1pgAvkNiNLUnGmJt68dtThdNTJZKJASDISH2+FZXsZiuK5zpEkIc1t8S M9qUaJWaDRX2+VZn6nYtHMkCc2YubQZgRHMsV.O4feF6qiBu5bT7Umiryl+O 3n5+Qho+RGU2XsymXmAzt. -----------end_max5_patcher-----------
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.
that was exactly what I was looking for. Thanks!
one of these days I really have to learn how to use regexp properly.
|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:
Then find pitch2midi.maxhelp in /CNMAT_MMJ-Depot/modules/MIDI/ Just what you want.
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…
Forums > MaxMSP