Forums > MaxMSP

Parsing Text

May 24, 2011 | 8:20 pm

Hi,

I’ve got a problem that to my mind should be kind simply to fix but after hours of searching can’t find anything.

Basically, my patch reads ID3 Tag data from an XML file, and splits it into individual lines that read like:

The Beatles
Revolver
Taxman

etc…

Is there anyway to get rid of the & parts. I’ve tried to do this with [sprintf] and [regexp] but am having no luck as MaxMSP reads it as one word.

Failing that is there a way it can be converted into numbers, something like unicode. As it’s use eventually will be to query a database.

Any tips would be great, cheers.


May 24, 2011 | 8:37 pm

regexp should do the trick:

– Pasted Max Patch, click to expand. –

Not sure if it is of interest to you, but Jeremy Bernstein made a nice object for reading id3 tags, metatag:

http://cycling74.com/forums/topic.php?id=28269

-Ben


May 24, 2011 | 9:16 pm

Cheers Ben, that’s exactly what I wanted, just hadn’t got round to learning the regexp syntax.

Will also check out Jeremy Bernstein’s object, looks very relevant to my project.


May 24, 2011 | 9:49 pm

Yeah, its a bit of a beast.

As far as learning the regexp syntax, here are a few useful ref links:

http://www.w3schools.com/jsref/jsref_obj_regexp.asp

http://www.regular-expressions.info/reference.html

There are some nifty tutorials out there too. I remember reading through this one and finding it useful:

http://www.learn-javascript-tutorial.com/RegularExpressions.cfm

-Ben


May 25, 2011 | 2:15 pm

there’s also tap.xml.sax from Electrotap’s Tap.Tools objects, which saves having to learn any regexp and also maintains structure…


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