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
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
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:57regexp 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.
mz
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...
Hi, I prefer not opening another topic...
I try to do something quite simple, but all this PCRE stuff is so weird to me.
So what I want to achieve is to process a file path like
"Macintosh HD:/Users/louiswarynski/Documents/Max/Max Patches Louis/MLR Video/Chapelier Monome Videos/Serpents/Serpent 16 onde.mp4"
to output
"Serpents/Serpent 16 onde.mp4"
So in other terms, everything after the penultimate "/"
Any help ?
Any resource to learn this stuff one and for all ?
this site is a good way to test regex. the Quick Reference is quite nice: https://regex101.com/
AI is quite helpful with regex too https://claude.ai/share/503136bd-34d2-44de-8d4e-bce364efbef3
From claude I got
[^/]+/[^/]+$Then plugging that into regex101 & fixing errors I get
[^\/]+\/[^\/]+$Then plugging that into max's regexp object makes the \ disappear so we need double \ for
regexp [^\\/]+\\/[^\\/]+$which works like so

In regexp you could do .+/(.+/.+) which will capture whatever that is before and after the last /, assuming there is another / before that part to capture, itself preceded by some other character.
. stands for any character
+ stands for "one or more occurrences" of the previous character (here .)
() defines the group to capture.
/ designates the actual / in the string.
I learnt this by reading countless times the examples provided in the [regexp] help file (which lacks clarity IMO) and by watching some video tutorials about regular expression (there are a lot of them).
I also provided another way of doing this based on the powerful [fromsymbol @separator /]:
for path -> "Folder/Filename.mp3" i´d go the atoi/itoa route, like i did for 110.stripfile (opposite of strippath)
You are all incredibly nice people !