Parsing Text

May 24, 2011 at 8:20pm

Parsing Text

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.

#57267
May 24, 2011 at 8:37pm

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

#205171
May 24, 2011 at 9:16pm

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.

#205172
May 24, 2011 at 9:49pm

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

#205173
May 25, 2011 at 2:15pm

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

#205174

You must be logged in to reply to this topic.