Forums > MaxMSP

Need to remove a comma from a message

Feb 02 2010 | 8:33 pm

message is "Boston, Massachusetts" so obviously Max parses it into 2 separate messages. How can I remove the comma, or better yet inject a / so that it is correctly read?

I also have messages like "Northern Peninsula, Alaska, USA". So there will be multiple instances of comma’s messing up my processing.

Feb 02 2010 | 9:45 pm


The first outlet of a [regexp , @substitute \,] will give you "Northern Peninsula, Alaska, USA".


Feb 02 2010 | 11:44 pm

thanks for that. It sorta solved my problem but ended up doing a different workaround. I have another dilemma now. I need to separate this message into month, date, year (2010-02-10). I assume I am using [regexp] again or something similar?

Feb 03 2010 | 12:13 am

regexp (\d+)-(\d)+-(\d+) should do it. \d represent a digit and the + is a quantifier which defines how many times the thing before (\d) appears. The parenthesis are used to create backreferences which are sent out the second outlet.

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

Feb 03 2010 | 12:23 am

If it is just the date string you are dealing with you could even use [regexp – @substitute " "] which will swap the -hyphens- for spaces and send the list from the first outlet, but this will only work if you have the correct formatting to start with.


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

Forums > MaxMSP