本帖最后由 llsheng_73 于 2024-1-19 16:24 编辑
- (defun StrType(a / b c d e);;字符串分离全角、符号、字母、数字,存在问题:连续小数点与数字相连不能精确分离数字和小数点
- (setq b(vl-string->list a))
- (while b
- (setq a(car b)b(cdr b)c(last d))
- (if(or(not d)
- (and(< 0 a 32)(< 0 c 32));;非打印字符
- (or(= 46 a)(= 46 c)(and(< 47 a 58)(< 47 c 58)));数字和小数点
- (vl-every'(lambda(x)(vl-some'(lambda(y)(<(car y)x(cadr y)))'((31 48)(57 65)(90 98)(122 129))))(list a c));其它字符包括小数点
- (vl-every'(lambda(x)(vl-some'(lambda(y)(<(car y)x(cadr y)))'((64 91)(96 123))))(list a c));;字母
- (and(> a 128)(> c 128)));;全角字符
- (if(> a 128)(setq d(vl-list*(car b)a d)b(cdr b))(setq d(cons a d)))
- (setq e(cons(reverse d)e)d(if(> a 128)(list(car b)a)(List a))b(if(> a 128)(cdr b)b))))
- (mapcar'vl-list->string(reverse(cons(reverse d)e))))
(vl-remove-if-not 'distof(StrType"免币123交流4.56收费78有理"))=>("123" "4.5" "678") |