Forums > Jitter

Crash with jit.str.regexp (with commas)

July 24, 2006 | 9:59 pm

Hi,

I’m trying to find a way to remove some html tags with jit.str.regexp.
With [jit.str.regexp @re /(< .*?>)/ @substitute " "] I can remove the tags, but I have a problem with commas: commas split my text in many lists…
What is the magic formula to keep the commas ?
Replacing all commas by "backslash comma" ( [,] –> [,] ) ?

I tried this:

max v2;
#N vpatcher 400 352 694 595;
#P window setfont "Sans Serif" 9.;
#P newex 35 61 95 196617 jit.str.fromsymbol;
#P newex 85 138 32 196617 print;
#P newex 85 115 80 196617 jit.str.tosymbol;
#P newex 35 85 213 196617 jit.str.regexp @re /(\\\,?)/ @substitute \,;
#P message 35 35 94 196617 Hello , the , world;
#P connect 0 0 4 0;
#P connect 4 0 1 0;
#P connect 1 1 2 0;
#P connect 2 0 3 0;
#P pop;

and I have a fabulous crash…
What is wrong ?
Is it a bug ?


July 25, 2006 | 4:46 pm

Thanks, I can confirm. Looks like jit.str.regexp needs some tuning up
to catch up with the vanilla regexp object.

jb

Am 24.07.2006 um 14:59 schrieb Thomas Goepfer:

> With [jit.str.regexp @re /(< .*?>)/ @substitute " "] I can remove
> the tags, but I have a problem with commas: commas split my text in
> many lists…


July 25, 2006 | 9:44 pm

I made 3 mistakes:
1) the box message should be [Hello, the, world], not [Hello, the, world]…
2) I should replace comma by [\,] not [,]
3) the syntax in jit.str.regexp seems wrong: [@re /(,?)/] crashes Max, but [@re /(,)/] works. (With the Max object "regexp", I have no crash, the first returns no result, but the second works fine))

I’m not very good in perl, and I don’t know why the first expression is bad.
But the crash…!

This is a good patch :
max v2;
#N vpatcher 400 352 694 595;
#P window setfont "Sans Serif" 9.;
#P newex 35 61 95 196617 jit.str.fromsymbol;
#P newex 84 138 32 196617 print;
#P newex 84 115 80 196617 jit.str.tosymbol;
#P newex 35 85 207 196617 jit.str.regexp @re /(\,)/ @substitute \\\,;
#P message 35 35 98 196617 Hello\, the\, world;
#P connect 0 0 4 0;
#P connect 4 0 1 0;
#P connect 1 1 2 0;
#P connect 2 0 3 0;
#P pop;


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