how to remove(strip) a character?

prko's icon

Dear users,

I want get only one letter from a string.
E.g.:
From Input1 just 1
From Output2 just 2

Does it work in MAX?

best,
prko

Luke Hall's icon

Have a look at [regexp], it's a bit complicated to understand but if you google "regular expressions" there are some excellent tutorials/manuals on the web.

lh

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

prko's icon

thanks!

Tj Shredder's icon

This works as well and is easier to understand than regexp...

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

BenCello's icon

Hi !
I second thereishopeforus, regexp is a lot more powerful when well used.Here is another example and another solution.

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

prko's icon

Thanks!
I understand now the regexp better!!!!
It is very wonderful explanation.

BenCello's icon

My pleasure, happy to help

prko's icon

one more question!

how can I get only numbers from the following two stirings?

symbol "1, 2, 3, 4, 5, 6, 7, 8"

and

symbol "1 2 3 4 5 6 7 8"

Regretfully, I have not found the syntax for this case....

best,
prko

Luke Hall's icon

Try [regexp , @substitute " "] for the first example, replacing ,commas, with spaces. The second case just needs a [fromsymbol].

lh

prko's icon

Thanks!

My solution is as follows:

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

Luke Hall's icon

Be warned that your example will only work for single digit numbers, if your list was "23 -6 3.1415" it wouldn't work. Try something like [regexp -?\d+\.?\d*] to check for larger numbers, negatives and decimals, if you need to.

lh