(setq strR (substr str (1+ (1+ (vl-string-search " " str))))
Strnn (vl-string-search ":" strR)
StrA (substr strR 1 Strnn)
Strz (substr StrR (1+ (1+ Strnn)))
) 谢谢Andyhon的帮助!问题基本解决,就怕有些人输入“DETAIL 2:1”时不输空格,如真那样就没辙了,不过这样的结果已经很可以了!TKS! 改下即可
(apply 'strcat(mapcar 'chr (vl-remove-if '(lambda (x) (or (> x 58)(< x 48))) (VL-STRING->LIST "DETAIL 2:1"))))
回复 Gu_xl 的帖子
都已经是2:1了,你自己还分不开吗? 回复 Gu_xl 的帖子
(setq OK (strcat "Andyhon" "+" "Gu_xl")) 搞定了!
版主批評的是,即使不會,也不要只會等著拿來就用,要學會變通! 不就OK了嗎!!!
(setq str (apply 'strcat(mapcar 'chr (vl-remove-if '(lambda (x) (or (> x 58)(< x 48))) (VL-STRING->LIST "DETAIL 2:1")))) )
(setq Strnn (vl-string-search ":" str)
StrA (substr str 1 Strnn)
Strz (substr Str (1+ (1+ Strnn)))
)
此問題已完全解決!!
但如有更好,更簡短,歡迎再討論!!! 要编程解决这种问题,必然你的字符串必须存在特定的规则,比如都是 Detail 开头, 后面接一个空格然后是 数字字符串:数字字符串.
用户选择后,如不符合的程序应该过滤掉. (mapcar 'chr (vl-remove-if '(lambda (x) (or (> x 58)(< x 48)))
(VL-STRING->LIST "DETAIL 15:21")))
("1" "5" ":" "2" "1")
分别将":"前与":"后的数字连起来即可。 (defun strim-ccm ( bk ax / b c)
(setq ax (vl-string-translate bk " " ax))
(while (setq c (vl-string-search " " ax))
(setq b(cons (substr ax 1 c) b)
ax (vl-string-trim " " (substr ax (1+ c)))
)
)
(setq b (cons ax b))
(reverse b)
)
指令: (strim-ccm ":" "detail 15 : 21")
("detail" "15" "21")
指令: (strim-ccm ":" "detail 15:21")
("detail" "15" "21")
页:
1
[2]