Forums > MaxMSP

Simple (?) Regexp parsing question.

Jun 22 2009 | 2:39 am

Trying to get some weather data…specifically I am trying to get the data here:

I want the value of text, temp and date…searched the forums and found a text message example and tried to edit it to suit my needs, but I don’t really know what I am doing.

— Pasted Max Patch, click to expand. —
Jun 22 2009 | 9:34 am

Try these [regexp]s. If you want me to explain them character by character so you get a better understanding then just let me know.


— Pasted Max Patch, click to expand. —
Jun 27 2009 | 2:08 am

Works well with the textbox, but not when I bang the line I want out of [text]….in [text] if there is the line:

it comes out as:


If its:

It comes out as:

Has no one written a proper string external that gets around all of max’s formatting?

the quotes/formatting gets all messed up…any way to fix that?

Jun 27 2009 | 4:50 am

Ok so I’m trying to hack together a .js that will scan lines and replace " with "

This code was working a bit ago, but now all of a sudden It wont compile

i send it the message

[readlines "path/data.txt"]

where path is the current filepath to my file…

// inlets and outlets
inlets = 2;
outlets = 2;

function readlines(s)
var f = new File(s);
var i, a, a0;

if (f.isopen) {

while (i<15){

if (f.readline()){
a = a0.replace(""", """, "gi");
outlet(0, a);
} else {
post("could not open file: " + s + "n");

What gives? The problem seems to be: a0.replace(""", """, "gi");

looks like """ gives the error..

Jun 27 2009 | 8:39 am

That’s because you need to escape characters even in javascript. "" Is an empty string so """ is an empty string followed by an illegal "quote". Try the line below which should work for you:

outlet(0, line.replace(""", "\"", "gi"));

The """ is an escaped quote mark as a string, the second is an escaped slash followed by an escaped quote mark as a string. It looks a bit odd but it fixes your problem. You could even do all the regexp parsing inside the javascript.


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

Forums > MaxMSP