Formatting text through [coll], and sanitizing text input

aceslowman's icon

This is the first time I've really delved into doing much with text in Max, so I've been rolling with some regex and text objects. The what I want to do is take in a large text file, and automatically break it up into individual words for flexible and fast retrieval. Thinking of doing some things with the statistical distribution of the words in the text.

So, currently it is working, in that I take in text, format it, and am outputting it. The problem here is that when it comes across words with reserved purposes in message objects (open, save, mode, etc), it recognizes them as commands. Is there a way to escape all of these words? Prepending doesn't seem to be working to insert into a coll object, and also I can't seem to tell whether or not I'm dealing with symbols, messages, or lists at any given time (which is because of my inexperience with text manipulation).

How can I get each of these words into the coll object properly and efficiently?

Max Patch
Copy patch and select New From Clipboard in Max.

Any advice would be greatly appreciated.

breton.txt
txt
Rick's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This might work for you. \\mode for mode

aceslowman's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thanks a ton Rick, I used what you brought up, and then just stripped out the \\ after it is processed by zl, which seemed to work. I still figure there has to be a more efficient way though, to process text that contains keywords for objects... oh well, if anyone knows of another way, enlighten us!