Forums > MaxMSP

textwrangler-like object

August 24, 2006 | 6:36 pm

Dear List,
I was wondering if anyone out there knows of an object or absraction or fix for my problem. What I would like to do is display the name of a movie on top of the movie by automatically making it a quicktime text track. That’s the easy part. The hard part is striping the .mov and other parts of the name which I don’t want displayed. For example, I’d like "miller1.mov" to become just "miller." Of course in Textwragler or whatever you can just delete the extension and last charater. How do you do this in max?
Many thanks,
Aaron



jln
August 24, 2006 | 7:07 pm


August 24, 2006 | 7:08 pm


August 24, 2006 | 7:09 pm

Regular expressions are great for this sort of thing. There is at least one
regular expression external. You can find it mentioned in the archive. Java
and JavaScript also support regular expressions.

(.*?).mov

or

([^.]+).mov

Dear List,
I was wondering if anyone out there knows of an object or absraction or fix
for my problem. What I would like to do is display the name of a movie on
top of the movie by automatically making it a quicktime text track. That’s
the easy part. The hard part is striping the .mov and other parts of the
name which I don’t want displayed. For example, I’d like "miller1.mov" to
become just "miller." Of course in Textwragler or whatever you can just
delete the extension and last charater. How do you do this in max?
Many thanks,
Aaron


August 24, 2006 | 7:41 pm

ahhh regexp. don’t know how i missed that one. many thanks to all.
-a



jln
August 24, 2006 | 7:58 pm


August 24, 2006 | 8:05 pm

yes. thank you. that is a huge help. if only the help files were like this…


August 24, 2006 | 8:28 pm


August 24, 2006 | 8:42 pm

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 68 221 83 196617 zip@knoware.nl;
#P newex 68 185 62 196617 prepend set;
#P newex 68 150 234 196617 regexp @re (\\w|@|\\.)(\\s)
@substitute %1%0;
#P message 68 123 119 196617 z i p @ k n o w a r e . n l;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P connect 2 0 3 0;
#P window clipboard copycount 4;

Am 24.08.2006 um 22:28 schrieb Zip Boterbloem:

> z i p @ k n o w a r e . n l


August 24, 2006 | 8:58 pm

Lovely. Could you explain it a bit, Jeremy? I would love to
understand what’s happening.

Best,

Zip

Zip Boterbloem
Media Mechanics
Zwaluwstraat 54
2025 VR Haarlem
The Netherlands
+31627014758
zip@knoware.nl

Op 24-aug-2006, om 22:42 heeft Jeremy Bernstein het volgende geschreven:

> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 68 221 83 196617 zip@knoware.nl;
> #P newex 68 185 62 196617 prepend set;
> #P newex 68 150 234 196617 regexp @re (\\w|@|\\.)(\\s)
> @substitute %1%0;
> #P message 68 123 119 196617 z i p @ k n o w a r e . n l;
> #P connect 1 0 2 0;
> #P connect 0 0 1 0;
> #P connect 2 0 3 0;
> #P window clipboard copycount 4;


August 24, 2006 | 9:12 pm

Here’s a better version:

[ regexp @re (\S)\s @substitute %1 ]

So, it goes through your string, looking for any non-whitespace
character (S) followed by a whitespace character (s). The non-
whitespace character is marked off as a backreference. It is the used
as the basis for a substitution %1, which means replace the entire
unit (non-whitespace + whitespace) and replace it with the first
backref (non-whitespace). Rinse and repeat.

The version in the patch I sent was all freaky because I was eating
soup at the same time I was writing it. Soup is known to temporarily
disrupt regular expressionism.

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 128 281 85 196617 zip@knoware.nl;
#P newex 128 245 62 196617 prepend set;
#P newex 128 213 182 196617 regexp @re (\\S)\\s @substitute %1;
#P message 128 183 119 196617 z i p @ k n o w a r e . n l;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P connect 2 0 3 0;
#P window clipboard copycount 4;

Am 24.08.2006 um 22:58 schrieb Zip Boterbloem:

> Lovely. Could you explain it a bit, Jeremy? I would love to
> understand what’s happening.
>
> Best,
>
> Zip
>
> Zip Boterbloem
> Media Mechanics
> Zwaluwstraat 54
> 2025 VR Haarlem
> The Netherlands
> +31627014758
> zip@knoware.nl
>
>
>
> Op 24-aug-2006, om 22:42 heeft Jeremy Bernstein het volgende
> geschreven:
>
>> #P window setfont "Sans Serif" 9.;
>> #P window linecount 1;
>> #P message 68 221 83 196617 zip@knoware.nl;
>> #P newex 68 185 62 196617 prepend set;
>> #P newex 68 150 234 196617 regexp @re (\\w|@|\\.)(\\s)
>> @substitute %1%0;
>> #P message 68 123 119 196617 z i p @ k n o w a r e . n l;
>> #P connect 1 0 2 0;
>> #P connect 0 0 1 0;
>> #P connect 2 0 3 0;
>> #P window clipboard copycount 4;
>


August 24, 2006 | 9:52 pm

Thanks for your explanation and the much clearer example. My
favourite soup is Tom Ka Kai, BTW.
You’ll find a recipe here: http://www.templeofthai.com/recipes/
chicken_coconut.php
Recommended.

Best,

Zip Boterbloem
Media Mechanics
Zwaluwstraat 54
2025 VR Haarlem
The Netherlands
+31627014758
zip@knoware.nl

Op 24-aug-2006, om 23:12 heeft Jeremy Bernstein het volgende geschreven:

> Here’s a better version:
>
> [ regexp @re (\S)\s @substitute %1 ]
>
> So, it goes through your string, looking for any non-whitespace
> character (S) followed by a whitespace character (s). The non-
> whitespace character is marked off as a backreference. It is the
> used as the basis for a substitution %1, which means replace the
> entire unit (non-whitespace + whitespace) and replace it with the
> first backref (non-whitespace). Rinse and repeat.
>
> The version in the patch I sent was all freaky because I was eating
> soup at the same time I was writing it. Soup is known to
> temporarily disrupt regular expressionism.
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 128 281 85 196617 zip@knoware.nl;
> #P newex 128 245 62 196617 prepend set;
> #P newex 128 213 182 196617 regexp @re (\\S)\\s @substitute %1;
> #P message 128 183 119 196617 z i p @ k n o w a r e . n l;
> #P connect 1 0 2 0;
> #P connect 0 0 1 0;
> #P connect 2 0 3 0;
> #P window clipboard copycount 4;
>
>
>
> Am 24.08.2006 um 22:58 schrieb Zip Boterbloem:
>
>> Lovely. Could you explain it a bit, Jeremy? I would love to
>> understand what’s happening.
>>
>> Best,
>>
>> Zip
>>
>> Zip Boterbloem
>> Media Mechanics
>> Zwaluwstraat 54
>> 2025 VR Haarlem
>> The Netherlands
>> +31627014758
>> zip@knoware.nl
>>
>>
>>
>> Op 24-aug-2006, om 22:42 heeft Jeremy Bernstein het volgende
>> geschreven:
>>
>>> #P window setfont "Sans Serif" 9.;
>>> #P window linecount 1;
>>> #P message 68 221 83 196617 zip@knoware.nl;
>>> #P newex 68 185 62 196617 prepend set;
>>> #P newex 68 150 234 196617 regexp @re (\\w|@|\\.)(\\s)
>>> @substitute %1%0;
>>> #P message 68 123 119 196617 z i p @ k n o w a r e . n l;
>>> #P connect 1 0 2 0;
>>> #P connect 0 0 1 0;
>>> #P connect 2 0 3 0;
>>> #P window clipboard copycount 4;
>>
>


August 27, 2006 | 3:26 pm

Jeremy Bernstein wrote:
> The version in the patch I sent was all freaky because I was eating
> soup at the same time I was writing it. Soup is known to temporarily
> disrupt regular expressionism.

Oh you lucky guy, to be in the state of having regular expressionism
temporarily disrupted, is something I’d love to be in… ;-)

Regexp reminds me of these one short line Lisp programs which would
cover several pages if you’d do them in C (or BASIC).

Wasn’t Peter Elsea some time ago seeking for new themes to make a
tutorial of? "Regular expressions in Max" would be a perfect one.

I was looking for some tutorials on the web, and what is missing for me
is a lot of examples with explanations. regexp.help unfortunately
doesn’t explain whats happening, and a list of "some" commands isn’t
very helpful, if you want to find out things with trial and error, you’d
need all. A link in the helpfile to web resources would be a good idea
as well…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


August 28, 2006 | 8:17 am

I would recommend downloading the (free) textwrangler from
http://www.barebones.com, go to the Help Viewer (choose User Manual from the
Help menu) and read the section called "Searching With Grep". It’s
the most useful and comprehensive guide to regular expressions that I
know.

I seem to remember that the O’Reilly JavaScript book has a good
chapter on regular expressions, as well – useful for users of the JS
object, or anyone who wants further insight into this arcane magic.

jb

Am 27.08.2006 um 17:26 schrieb Stefan Tiedje:

> Wasn’t Peter Elsea some time ago seeking for new themes to make a
> tutorial of? "Regular expressions in Max" would be a perfect one.


August 28, 2006 | 8:32 am

I’d love a Chelsea tutorial on regular expressions too…

Zip Boterbloem
Media Mechanics
Zwaluwstraat 54
2025 VR Haarlem
The Netherlands
+31627014758
zip@knoware.nl

Op 27-aug-2006, om 17:26 heeft Stefan Tiedje het volgende geschreven:

> Jeremy Bernstein wrote:
>> The version in the patch I sent was all freaky because I was
>> eating soup at the same time I was writing it. Soup is known to
>> temporarily disrupt regular expressionism.
>
> Oh you lucky guy, to be in the state of having regular expressionism
> temporarily disrupted, is something I’d love to be in… ;-)
>
> Regexp reminds me of these one short line Lisp programs which would
> cover several pages if you’d do them in C (or BASIC).
>
> Wasn’t Peter Elsea some time ago seeking for new themes to make a
> tutorial of? "Regular expressions in Max" would be a perfect one.
>
> I was looking for some tutorials on the web, and what is missing
> for me
> is a lot of examples with explanations. regexp.help unfortunately
> doesn’t explain whats happening, and a list of "some" commands isn’t
> very helpful, if you want to find out things with trial and error,
> you’d
> need all. A link in the helpfile to web resources would be a good idea
> as well…
>
> Stefan
>
> —
> Stefan Tiedje————x——-
> –_____———–|————–
> –(_|_ —-|—–|—–()——-
> — _|_)—-|—–()————–
> ———-()——–www.ccmix.com
>
>


September 2, 2006 | 10:47 am

Jeremy Bernstein wrote:
> I would recommend downloading the (free) textwrangler from
> http://www.barebones.com, go to the Help Viewer (choose User Manual from the
> Help menu) and read the section called "Searching With Grep". It’s the
> most useful and comprehensive guide to regular expressions that I know.

Thanks for that hint, I didn’t know that Grep is actually using regular
expressions. I never tried it and heard only wonderous stories…
I am actually using textwrangler as standard editor for textbased Max
editing for quite a while, but never really got into the inner details
of it. But now I will ;-)
This will simplify some of my abhaXions a lot…
I guess regexp is more effective than a bunch of atoi-zl something-itoa
constructions…

Stefan


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


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