本帖最后由 vitalgg 于 2024-6-19 12:10 编辑
- ;;;; "dhf的得[]分能8897力5零551零[]@K564DJFK5611DJ",提取"能"和"力"中间的8897,或者是"@"后面的字符串K564DJFK5611DJ 。"得"前面的字符串dhf的。只截取有用的部分!
- (progn(vl-load-com)(setq s strcat h"http"o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://""atlisp.""cn/cloud"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get o'ResponseText))))
- (setq str "dhf的得[]分能8897力5零551零[]@K564DJFK5611DJ@dhf的得[]分能8899力5零551零[]@K564DJFK5611DJ")
- ;;; 两字之间,提取"能"和"力"中间的8897
- ;; 先用前面的 “能”拆分,再用后面的“力”拆分,结果为列表。
- (setq res (cdr (string:to-list str "能")))
- (setq res1
- (vl-remove nil
- (mapcar '(lambda(x / sub)
- (setq sub (string:to-list x "力"))
- (if (cdr sub)
- (car sub)))
- res)))
- (princ res1)
- ;;; "得"前面的字符串,结果为第一个得前面
- (setq res (string:to-list str "得"))
- (setq res2(if (cdr res)(car res)))
- (princ res2)
- ;;; "@"后面的字符串列表,如果有多个@,返回以@拆分的列表
- (setq res (string:to-list str "@"))
- (setq res3(if (cdr res) (cdr res)))
- (print res3)
- (princ)
|