本帖最后由 yuanziyou 于 2012-12-25 14:51 编辑
非常感谢!我已经把2个函数揉合了,一个就是g版的排序,另外一个论坛里搜索的正则表达式,完美解决 - (defun sort (l)
- (vl-sort l
- '(lambda (a b / a1 a2 b1 b2)
- (setq a1 (zzth (car a) "[0-9]")
- a2 (zzth (car a) "[^0-9]")
- b1 (zzth (car b) "[0-9]")
- b2 (zzth (car b) "[^0-9]")
- )
- (if (= a1 b1)
- (< (atof a2) (atof b2))
- (< a1 b1)
- )
- )
- )
- )
- (defun zzth (str gz / regex)
- (vl-load-com)
- (setq regex (vlax-create-object "Vbscript.RegExp"))
- (vlax-put-property regex "IgnoreCase" 0)
- (vlax-put-property regex "Global" 1)
- (vlax-put-property regex "Pattern" gz)
- (setq str (vlax-invoke-method regex "Replace" str ""))
- )
|