Forums > MaxMSP

regexp won't export "number 00"


Ad.
March 9, 2014 | 11:34 am

Hello all !

weird stuff.

I use regexp to export name of files…

weird stuff because with (.*) , 007 becomes 7…

see the patch attached to demonstrates my issue.
thanks in advance:

<pre><code>

– Pasted Max Patch, click to expand. –

</code></pre>


March 12, 2014 | 3:08 am

It seems to come down to this:

007 has the same value as 7. Numbers are all about value. Therefore, 007 is 7. And because the same thing can’t be different (or it wouldn’t be the same)… off with the zeros. Like heads rolling. That may seem shallow and brutal and stupid for us artists, but for a computer, it’s sublime.

Good thing we have symbols.

– Pasted Max Patch, click to expand. –

March 13, 2014 | 4:59 pm

That may seem shallow and brutal and stupid for us artists, but for a computer, it’s sublime.

! :)

i was wondering if it was possible to keep the possiblity of having other extensions than jpg, it is (regexp is complex)

<code>

– Pasted Max Patch, click to expand. –

</code>

but no success trying to get that 007 as a backreference. Is @tosymbol 1 only working on the substitutions result ? it is a bit weird…


March 13, 2014 | 5:24 pm

Ah yes, much better… and you’re correct.. tosymbol only works for substitutions. :/

from the reference docs:

"When enabled, output from the left outlet of the object will be a single symbol. When disabled, output from the left outlet of the object will consist of a list of individual elements."

But there must be some way to specify everything before the last / and after the . as a single group to be substituted. But I couldn’t figure it out.. hence my clunky use of two objects to handle it.



ak
March 13, 2014 | 9:02 pm

This does the magic:

<code>

– Pasted Max Patch, click to expand. –

</code>


March 13, 2014 | 9:51 pm

Nice!

Should I generally assume that any element proceeding .* will reference the last instance of that element? In this case, there were multiple slashes. Some of my initial attempts generated weird slicing at the first or middle slash.


March 14, 2014 | 3:09 am

Hah Ak, it is nice, though i don’t get it… where is the "capture group" for the substitution in what you just made ? and how comes a "or" operator does the trick… from my undertstanding the "or" here matches "/" or "\." .. or does it mean "substitute anything that is either ‘.*/’ or ‘\..*’ " ???
edit : oh, ok, so it seems to be that indeed, and it works also if reversing the ‘.*/’ and ‘\..*’. Interesting !

<code>

– Pasted Max Patch, click to expand. –

</code>



Ad.
March 14, 2014 | 3:18 am

wow !!!
really nice !!
thanks to all !!!


March 14, 2014 | 3:33 am

Vichug, my friend, what is this "either" of which you speak? :)

OR = + = Union

Attachments:
  1. OR

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