Forums > MaxMSP

Can I get rid of backslashes?

February 9, 2008 | 1:26 am

How can I have something like a textedit that doesn’t interpret special characters like comma, semicolon, and double quotes? In other words can I input text and automatically escape these special characters?

So I want to type things like:
this, is, a, single, message
but have it act like:
this, is, a, single, message

And things like:
"this is four symbols"
should act like:
"this is four symbols"

I’m guessing it’s not possible with the built in objects. Maybe using Swing in a Java/mxj object I can make a text input that does this? Any better ideas?


February 9, 2008 | 10:34 am

maybe this would be a job for [regexp] or [jit.str.regexp].
i am really badly versed in the regular expressions stuff but here is a patch posted by someone ( apologies to the author , i cant remember who it was ) that does the exact opposite of what you are looking for , it could lead you to the right direction .
sorry for not being more helpfull :(

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 95 121 95 196617 jit.str.fromsymbol;
#P newex 144 195 32 196617 print;
#P newex 144 172 80 196617 jit.str.tosymbol;
#P newex 95 145 207 196617 jit.str.regexp @re /(\,)/ @substitute \\\,;
#P message 95 95 98 196617 Hello\, the\, world;
#P connect 1 1 2 0;
#P connect 4 0 1 0;
#P connect 2 0 3 0;
#P connect 0 0 4 0;
#P window clipboard copycount 5;

Quote: Adam Murray (adamj) wrote on Sat, 09 February 2008 02:26
—————————————————-
> How can I have something like a textedit that doesn’t interpret special characters like comma, semicolon, and double quotes? In other words can I input text and automatically escape these special characters?
>
> So I want to type things like:
> this, is, a, single, message
> but have it act like:
> this, is, a, single, message
>
> And things like:
> "this is four symbols"
> should act like:
> "this is four symbols"
>
> I’m guessing it’s not possible with the built in objects. Maybe using Swing in a Java/mxj object I can make a text input that does this? Any better ideas?
>
>
—————————————————-



ico
February 9, 2008 | 4:08 pm

regexp object. See perl syntax on how to do thi.

Best wishes,

Ico

> —–Original Message—–
> From: maxmsp-bounces@cycling74.com [mailto:maxmsp-bounces@cycling74.com]
> On Behalf Of Adam Murray
> Sent: Friday, February 08, 2008 8:27 PM
> Subject: [maxmsp] Can I get rid of backslashes?
>
>
> How can I have something like a textedit that doesn’t interpret special
> characters like comma, semicolon, and double quotes? In other words can I
> input text and automatically escape these special characters?
>
> So I want to type things like:
> this, is, a, single, message
> but have it act like:
> this, is, a, single, message
>
> And things like:
> "this is four symbols"
> should act like:
> "this is four symbols"
>
> I’m guessing it’s not possible with the built in objects. Maybe using
> Swing in a Java/mxj object I can make a text input that does this? Any
> better ideas?
>
>
> –
> Adam Murray
> compusition.com


February 10, 2008 | 8:04 am

Thanks for the replies.

regexp would work, but is there a way to do a replace all when substituting? Something equivalent to the ‘g’ (global) option in standard/Perl regex? I can replace a comma with backslash comma but it only replaces one comma:

#P newex 118 246 32 196617 print;
#P message 244 143 110 196617 substitute %1\\\,%2;
#P button 118 130 15 0;
#P newex 118 221 90 196617 regexp (.*)\,(.*);
#P user textedit 118 153 218 203 32896 3 9 [1 , 2 , 3];
#P connect 1 0 4 0;
#P connect 0 0 1 0;
#P fasten 3 0 1 0 249 212 123 212;
#P connect 2 0 0 0;

I guess I’d have to loop the operation until the regexp doesn’t match anymore.

Anyway, I somehow overlooked the "Output as One Symbol" option in textedit’s inspector. That mostly solves my problems so I’m just going to use that for now.


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