get integer from text?

woodslanding's icon

I just want to create the string "text.2" by splitting "text.1" into "text" and "1" (I found a tokenizer to do that) and then increment the 1. Problem is converting "1" into an integer value.

I've looked all through the docs, and am not finding it. Thanks for any tip.

-e

Luke Hall's icon
Max Patch
Copy patch and select New From Clipboard in Max.

The [regexp] object is good for this sort of task.

cbm's icon
Max Patch
Copy patch and select New From Clipboard in Max.

woodslanding's icon

thanks!

I would not have thought of that.... I need to study regex a bit!

Chris Muir's icon

regex take more than a bit of study. Every time I try to use it, I go back to studying it.

(btw: I'm cbm as well as Chris Muir. For some reason I ended up with two accounts.)

xidance's icon

"regex take more than a bit of study. Every time I try to use it, I go back to studying it."

Max Patch
Copy patch and select New From Clipboard in Max.

that's exactly what it looks like, the only of max' more complex modules i never used. doing that sort of with [atoi] and [zl], looks ugly but at least i understand what it is doing (the patch is slightely fattened up by the option of having numbers greater than 9) ;)

seejayjames's icon

...exactly, it's utterly and completely logical, yet looks completely illogical and seems impossible to decipher...

xidance's icon

maybe not so much to decipher but to memorize in detail.

woodslanding's icon

Well, I found a much more comprehensible way to do it using fromSymbol--that's the max module I was looking for.... I use my string tokenizer into zl ecils, and the second out goes to fromSymbol. Works great, and doesn't mind spaces prior to the number.

But I still feel I should figure out regex. It's a crazy powerful tool....

....but maybe not today ;)

dhjdhjdhj's icon

A good place to learn about regex is http://www.regular-expressions.info/tutorial.html

There are also many good tools to help create and test regular expressions.

xidance's icon

ah ok thanks.

Luke Hall's icon

You can also click on this link or where it says "1 tool" under my name on the left to see a regular expression guide I put together in Max to help people understand it's mystic power!