本帖最后由 xshrimp 于 2012-7-5 14:39 编辑
- (defun gxl (s / dot)
- (
- (lambda (l )
- (read
- (strcat "("
- (vl-list->string
- (apply
- 'append
- (mapcar
- (function
- (lambda (a b c d)
- (if
- (or
- (< 47 b 58)
- (and (= 43 b) (< 47 c 58) )
- (and (= 45 b) (< 47 c 58) )
- (and (= 46 b) (< 47 a 58) (< 47 c 58))
- (and (= 46 b) (not (< 47 a 58)) (< 47 c 58))
- (and (= 46 b) (< 47 a 58) (not (< 47 c 58)))
- (and (or (= 69 b)(= 101 b)) (< 47 a 58) (or (< 47 c 58) (and (or (= 43 c) (= 45 c)) (< 47 d 58))))
- )
- (if (and (= 46 b) (not (< 47 a 58)) (< 47 c 58))
- (if (not dot)
- (progn (setq dot t) (list 48 b))
- (list 48 b)
- )
- (if (and (= 46 b) (< 47 a 58) (not (< 47 c 58)))
- (if (not dot)
- (list b 48 32)
- (progn (setq dot nil) (list 32 ))
- )
- (if (and (< 47 b 58) (= 45 c))
- (progn (setq dot nil) (list b 32))
- (if (and (= 46 b) (< 47 a 58) (< 47 c 58))
- (if (not dot)
- (progn (setq dot t) (list b))
- (progn (setq dot t) (list 32 48 b))
- )
- (list b)
- )
- )
- )
- )
- (progn (setq dot nil) '(32))
- )
- )
- )
- (cons nil l)
- l
- (append (cdr l) (list nil))
- (append (cddr l) (list nil nil))
- )
- )
- )
- ")"
- )
- )
- )
- (vl-string->list s)
- )
- )
- (defun qjchen (s / lst regex x)
- (setq regex (vlax-create-object "VBScript.RegExp"))
- (vlax-put-property regex 'global actrue)
- (vlax-put-property regex 'pattern "[-+]?(\\d+)?[.]?(\\d+)([Ee][+-](\\d+))?")
- (vlax-for x (vlax-invoke regex 'execute s)
- (setq lst (cons (atof (vlax-get x 'value)) lst))
- )
- (vlax-release-object regex)
- (reverse lst)
- )
(list "1.1.1.1" "5e-0.5A12" "5e0.5A12" "AB0.125e5C+-.2.2D3")
正确返回值
((1.1 0.1 0.1) (5 -0.5 12) (5 0.5 12) (12500.0 0.2 0.2 3))
(mapcar 'gxl (list "1.1.1.1" "5e-0.5A12" "5e0.5A12" "AB0.125e5C+-.2.2D3"))
=>((1.1 0.1 0.1) (5E-0 12) (5E0 12) (12500.0 0.2 0.2 3))
(mapcar 'qjchen (list "1.1.1.1" "5e-0.5A12" "5e0.5A12" "AB0.125e5C+-.2.2D3"))
=>((1.1 0.1 0.1) (5.0 0.5 12.0) (5.0 0.5 12.0) (0.125 5.0 -0.2 0.2 3.0))
|