(defun remalph3 ( s )
(if (wcmatch (strcase s t) "*[a-z ]*")
(remalph
(vl-string-subst "" " "
(vl-string-subst "" "a"
(vl-string-subst "" "b"
(vl-string-subst "" "c"
(vl-string-subst "" "d"
(vl-string-subst "" "e"
(vl-string-subst "" "f"
(vl-string-subst "" "g"
(vl-string-subst "" "h"
(vl-string-subst "" "i"
(vl-string-subst "" "j"
(vl-string-subst "" "k"
(vl-string-subst "" "l"
(vl-string-subst "" "m"
(vl-string-subst "" "n"
(vl-string-subst "" "o"
(vl-string-subst "" "p"
(vl-string-subst "" "q"
(vl-string-subst "" "r"
(vl-string-subst "" "s"
(vl-string-subst "" "t"
(vl-string-subst "" "u"
(vl-string-subst "" "v"
(vl-string-subst "" "w"
(vl-string-subst "" "x"
(vl-string-subst "" "y"
(vl-string-subst "" "z" (strcase s t))
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
s
)
)
(vl-string-trim "abcdefghijklmnopqrstuvwxyz " s)
_$ (mapcar '(lambda (s) (cons s (str-filter s "[0-9],`-,`.")))
'("32c" "123.5 cm" "- 12.3" "x 28"))
(("32c" . "32") ("123.5 cm" . "123.5") ("- 12.3" . "-12.3") ("x 28" . "28"))
It seems to work as expected for the OP's samples:Actually that wcmatch filter can be slightly reduced:
_$ (mapcar '(lambda (s) (cons s (str-filter s "[0-9.],-")))
'("32c" "123.5 cm" "- 12.3" "x 28"))
(("32c" . "32") ("123.5 cm" . "123.5") ("- 12.3" . "-12.3") ("x 28" . "28"))
It seems to work as expected for the OP's samples:Actually that wcmatch filter can be slightly reduced:Code: [Select]_$ (mapcar '(lambda (s) (cons s (str-filter s "[0-9.],-")))
'("32c" "123.5 cm" "- 12.3" "x 28"))
(("32c" . "32") ("123.5 cm" . "123.5") ("- 12.3" . "-12.3") ("x 28" . "28"))
in a simple case the easiest is:Code: [Select](vl-string-trim "abcdefghijklmnopqrstuvwxyz " s)
Be careful with this method ;-)Actually even one of the OP's samples don't work with that:Code - Auto/Visual Lisp: [Select]
"123abc456"
_$ (vl-string-trim "abcdefghijklmnopqrstuvwxyz " "- 12.3")
"- 12.3"
Or just:Awesome, thanks! Had an issue when I added the minus sign - prefixed it with a back-quote which then didn't work, so I left that on the outside of the wcmatch option group. Didn't realize that a dash is ignored if there's nothing following it.Code - Auto/Visual Lisp: [Select]