cut words, keep others

Nov 1, 2008 at 12:02pm

cut words, keep others

Hello,

I have this message:

qwe

I’d like to cut “qwe” and keep

How can I do that?

Thank you.

#40601
Nov 1, 2008 at 12:15pm

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

#143761
Nov 1, 2008 at 1:38pm

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?

#143762
Nov 1, 2008 at 2:10pm

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. –
#143763
Nov 1, 2008 at 2:56pm

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. –
#143764
Nov 1, 2008 at 4:13pm

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

Could you post a screen capture?

#143765
Nov 1, 2008 at 4:19pm

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

#143766
Nov 1, 2008 at 5:01pm

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

#143767
Nov 1, 2008 at 6:33pm

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;

#143768
Nov 1, 2008 at 7:39pm

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
>

#143769
Nov 1, 2008 at 8:11pm

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

#143770
Nov 1, 2008 at 8:53pm

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.

#143771
Nov 1, 2008 at 9:00pm

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

#143772
Nov 5, 2008 at 8:06pm

Yes ej.

anyway thanks to all.

#143773

You must be logged in to reply to this topic.