Forums > MaxMSP

automatically turn "message," into "message/,"

Jun 26 2013 | 6:33 pm

I’m hoping somebody can help me with a problem I’m having. I’m basically trying to route a whole bunch of text automatically downloaded from a web page and analyze it but I’ve run into a problem with commas. My objects automatically filter out the commas in the text as message separators. Now I know if you put a / before the comma it won’t be treated as a message separator, but is there some sort of combination of objects that would be able to do this automatically? I’m dealing with quite a large volume of text so I can’t afford to put all the / in myself.

Jun 27 2013 | 1:44 am

mayyybe there is something to do with [tosymbol] ? or with [regexp] eg [regepx \, @substitute \\\,] or [sprintf] ? but it’s hard to help you wihtout example, in particular : how do you download said text ? if the problem is directly out of an object that downloads the text it might be less easy….
edit : i doubt any of those tricks would work, because as soon as a message is parsed, it’s more than one message. maybe you’d have more luck with some zl magic, by reuniting the text obtained ?

Jun 27 2013 | 2:06 am

Ah, I had a look at regexp and it looked like it should have worked but it looks like the comma is gone the second it enters the inlet, here’s the part of my patch that downloads the text, followed by some objects that get rid of the of the html formatting and outputs each word individually as a long string of messages, if you execute the download then look at the text file the commas are there, but the second they go through another object they’re gone.

-- Pasted Max Patch, click to expand. --


Jun 27 2013 | 2:07 am

in your example i’m not sure how you output the text from your [text]. If you use dump, at the end of the chain each string is separated…if that’s not the problem, then

[regexp , @substitute \\,]
[route set]

should be enough to keep the comas at the end.
edit : actually you also need to connect the third outlet of regexp (unmatched) to output lines that don’t have comas in them.

Jun 27 2013 | 2:38 am

That’s right I’m using dump to output the text, I forgot to include it in the pasted patch as it’s part of a trigger involving other objects.

It seems like in theory your setup with the regexp should work, but I’m not getting anything, I think regexp is still treating the commas as message separators. Even if you tell it to look for them, it seems like it only tries to look for them after filtering them out.

Why would I need to connect the unmatched outlet of regexp?

I realised that if you have a [message,] and you manually put quotes around it ["message,"] it will turn it into [message\,] automatically, but if you try to use tosymbol which normally does this it won’t do it because it’s not a list input

At the moment it looks like something that may have to be addressed by c74 or it has no possible solution…

Jun 27 2013 | 10:04 am

I do not know for what you are looking exactly regarding your text processing, but in the attached patch you may find some hints.
Hope this helps

-- Pasted Max Patch, click to expand. --


Jun 27 2013 | 10:21 am

or this…

— Pasted Max Patch, click to expand. —
Jun 27 2013 | 7:25 pm

Thanks, well one thing I figured out is that it’s supposed to be a \ and not a /

The second patch you pasted works on some text in lines 6 and 7, but this appears to be because they are enclosed in quotes, specifying that area of the text as a whole symbol, thus the regexp can do its thing but all commas not enclosed in quotes get lost as before. Maybe it’s worth trying to find a way to automatically enclose each entire line of the text in quotes, so the regexp can affect them and they can then go through [zl group 1] with the commas preserved. It doesn’t seem possible with the current text object as I can’t find a command that sets the pointer to the beginning of a line but maybe there’s some kind of external or other software that can affect the text file..

Jun 27 2013 | 9:39 pm

Well it looks like I found a workable solution using open source software called Auto Hot Key ( to quickly put quotes at the beginning and end of each line of the html file, allowing regexp to treat each line as a whole symbol and preserve the commas. Thanks for help with regexp!

-- Pasted Max Patch, click to expand. --


Jun 28 2013 | 2:01 am

For anybody interested in my solution this is my end result

-- Pasted Max Patch, click to expand. --


And this is my AHK script (just hold Q til you’re at the last line):

send {Home}
send "
send {End}
send "
send {NumpadDown}

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

Forums > MaxMSP