Forums > MaxMSP

cut words, keep others

November 1, 2008 | 12:02 pm

Hello,

I have this message:

qwe

I’d like to cut "qwe" and keep

How can I do that?

Thank you.


November 1, 2008 | 12:15 pm

On 1 nov. 08, at 13:02, Derrick Giscloux wrote:

> Hello,
>
> I have this message:
>
> qwe
>
> I’d like to cut "qwe" and keep

>
> How can I do that?

It depends: [route qwe], [zl filter qwe].

ej


November 1, 2008 | 1:38 pm

No sorry,

qwe could be anything as well as

In fact I want to keep what is inside <>

I had a look at [detox] but the tag is invalid.

The structure of the messages I want to process is:

something

I just want to keep

Is it clear?


November 1, 2008 | 2:10 pm

On 1 nov. 08, at 14:39, Derrick Giscloux wrote:

> Is it clear?

yep. regexp is the way to go.

]+> means: you look for the character " ([^>] is a negative class),
followed by a ‘>’.

HTH,
ej

– Pasted Max Patch, click to expand. –

November 1, 2008 | 2:56 pm

this is easy to achieve with the c-string functions externals in my
collection, here just one way of doing this:

hth

/*j

– Pasted Max Patch, click to expand. –

November 1, 2008 | 4:13 pm

Thanks!
It is great .. but … I am still on 4.6.3

Could you post a screen capture?


November 1, 2008 | 4:19 pm

On 1 nov. 08, at 17:13, Derrick Giscloux wrote:

> Thanks!
> It is great .. but … I am still on 4.6.3
>
> Could you post a screen capture?

Just use:

regexp < [^>]+>

and take the third outlet (substrings).

ej


November 1, 2008 | 5:01 pm

how about a message box with a $2 in it?


November 1, 2008 | 6:33 pm

here’s a patch for 4.x.x

/*j

> It is great .. but … I am still on 4.6.3

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 181 265 81 196617 open/close gate;
#P comment 255 238 103 196617 both conditions met?;
#P comment 324 208 81 196617 > at pos len-1 ?;
#P newex 138 304 32 196617 print;
#P newex 178 233 71 196617 &&;
#P newex 239 206 75 196617 == 0;
#P newex 178 207 31 196617 == 0;
#P newex 304 182 27 196617 – 1;
#P newex 304 156 37 196617 strlen;
#P newex 239 156 52 196617 strcspn >;
#P newex 178 156 52 196617 strcspn < ;
#P newex 138 280 29 196617 gate;
#P newex 157 114 47 196617 zl iter 1;
#P message 317 76 135 196617 qwe something ;
#P message 220 76 86 196617 something
;
#P message 157 76 56 196617 qwe ;
#P comment 97 158 63 196617 < at pos 0 ?;
#P connect 4 0 5 1;
#P connect 4 0 6 0;
#P connect 4 0 7 0;
#P connect 4 0 8 0;
#P connect 5 0 13 0;
#P connect 12 0 5 0;
#P connect 11 0 12 1;
#P connect 10 0 12 0;
#P connect 9 0 11 1;
#P connect 7 0 11 0;
#P connect 6 0 10 0;
#P connect 8 0 9 0;
#P connect 2 0 4 0;
#P connect 3 0 4 0;
#P connect 1 0 4 0;
#P window clipboard copycount 17;


November 1, 2008 | 7:39 pm

Once again a win for regular expressions.

Can someone please refresh my memory; are there any maxMSP-specific
tutorials going *DEEP* into regexp use?

I know there are books and websites and such dealing with regular
expressions on the whole, but something specific to max, going above and
beyond the help files would really be killer.

Perhaps as an article on cycling74.com? (if it isn’t there already… ahem.)

Cheers,
Andreas.

Emmanuel Jourdan skrev:
> Just use:
>
> regexp < [^>]+>
>
> and take the third outlet (substrings).
>
> ej
>


November 1, 2008 | 8:11 pm

On 1 nov. 08, at 20:39, Andreas Wetterberg wrote:

> Once again a win for regular expressions.
>
> Can someone please refresh my memory; are there any maxMSP-specific
> tutorials going *DEEP* into regexp use?
>
> I know there are books and websites and such dealing with regular
> expressions on the whole, but something specific to max, going above
> and beyond the help files would really be killer.
>
> Perhaps as an article on cycling74.com? (if it isn’t there
> already… ahem.)

It’s complicated to document such kind of thing, as you said, there
are already tons of awesome book on the subject (I highly recommend
"Mastering Regular Expression" from Jeffrey Friedl, O’Reilly). Note
that in the regexp’s help file of Max 5 there’s a few more concret
examples.

There’s no dedicated regexp article, but you can find some funny one
here, which will give you some ideas about what you can do:

http://www.cycling74.com/story/2008/6/2/161813/1326

ej


November 1, 2008 | 8:53 pm

I think you guys are thinking about this too hard.

If it’s just a 2-element list like:

qwe asd

and you want to turn that into:

asd

then all you have to do is put it through a message box with $2 in it, to take the second element of the list. If it’s not already a list (i.e. if it’s a symbol) then just put it through a fromsymbol object first.

If the list might sometimes be longer than two elements, then just simply use a zl object. For instance, if the list is:

qwe asd fqu ajl qke rjrjrjrjr 0 0 2134.3

and you want to turn that into:

asd fqu ajl qke rjrjrjrjr 0 0 2134.3

then just put it through a [zl slice 1] object, and take the output of the second outlet. Again, if the initial message is in symbol form, just run it through a fromsymbol object.


November 1, 2008 | 9:00 pm

On 1 nov. 08, at 21:53, Scott wrote:

> I think you guys are thinking about this too hard.

Unless I’m mistaken what Derrick wants is to find elements which start
with a ‘< ' and finish with a '>‘.

ej


November 5, 2008 | 8:06 pm

Yes ej.

anyway thanks to all.


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