@Kent1Cooper wrote:
.... wouldn't you want it to return 24721206 from the example above? If not, BeekeeCZ's suggestion will not do what you want -- how is a routine supposed to know that it should not keep the 6?
Yes, I guess maybe [I didn't test it] it will -- I hadn't looked closely enough to notice the "Until/" part. But is that really a cut-off that you want? Nothing about the example in your original question compares to that.
I also wonder about the operation you need. That routine asks you to select an object, but only returns the adjusted string, and doesn't change the text content of the object. If you have many objects, do you want to run a command separately on each one? Or select many and have it run on all of them? What do you want to do with the results? Change the content of the selected objects? Put them into new Text/Mtext, or into a Table? Send them to an external file? Etc., etc.
If you really do want all the numerical characters, here's the approach in Martti's routine, with the stop-at-/ aspect removed, as a function with a string argument, rather than a command with object selection, and returning the revised string to do with what you want:
(defun RNO (str); = Return Number(s) Only
(vl-list->string
(vl-remove-if-not
'(lambda (x) (< 47 x 58))
(vl-string->list str)
); vl-remove-if-not
); vl-list->string
); defun
Kent Cooper, AIA