- UID
- 6847
- 积分
- 1065
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-6-23
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
;;;;提取字串中的数字,lst ( "+" ".") 需要当作数字处理的符号
(defun zgx-find-num (str lst / rtn-str rtn-str1 lst) ;rtn-str)
(setq rtn-str ""
rtn-str1 ""
lst nil
)
(while (/= str "")
(if (zgx-singlestr-if-num (zgx-substr str 1 1) lst)
(progn
(setq rtn-str (strcat rtn-str (zgx-substr str 1 1))
str (zgx-substr str 2 0)
)
(while (zgx-singlestr-if-num (zgx-substr str 1 1) lst)
(setq rtn-str (strcat rtn-str
(zgx-substr str 1 1)
)
str (zgx-substr str 2 0)
)
)
(setq lst (append lst (list rtn-str)))
(setq rtn-str "")
)
(progn
(setq rtn-str1 (zgx-substr str 1 1)
str (zgx-substr str 2 0)
)
(while
(and
(not (zgx-singlestr-if-num (zgx-substr str 1 1)
lst
)
)
(/= str "")
)
(setq rtn-str1 (strcat rtn-str1
(zgx-substr str 1 1)
)
str (zgx-substr str 2 0)
)
)
(setq lst (append lst (list rtn-str1)))
(setq rtn-str1 "")
)
)
)
lst
)
;;-----判断是否为英文字符----------------
(defun zgx-singlestr-if-letter (str)
(if (wcmatch str (strcat str "*"))
t
nil
)
)
;;;-----判断单个字母是否为数字,lst ( "+" ".") 需要当作数字处理的符号------
(defun zgx-singlestr-if-num (str lst)
(if (or
(wcmatch str "#")
(member str lst)
)
t
nil
)
)
;;;---判断整个单词是否为数字,lst ( "+" ".") 需要当作数字处理的符号----------
(defun zgx-wholestr-if-num (str lst / yes)
(setq yes t)
(while (and
(/= "" str)
yes
)
(if (zgx-singlestr-if-num (zgx-substr str 1 1) lst)
(setq str (zgx-substr str 2 1))
(setq yes nil)
)
)
yes
)
;;------字符串长度,汉字按一个字符计算------------------
(defun zgx-strlen (str / m n)
(setq m 0)
(while (/= str "")
(if (zgx-singlestr-if-letter (substr str 1 1))
(setq n 1)
(setq n 2)
)
(setq str (substr str (+ 1 n)))
(setq m (1+ m))
)
m
)
;;-------取代substr,汉字按一个字符计算,n<0 则substr str m,否则substr m n-----------------
(defun zgx-substr (str m n / mm nn teststr kk str1)
(if (= m 0)
(setq str1 str)
(progn
(setq mm 0
nn 0
)
(repeat (- m 1)
(if (and
str
(/= "" str)
)
(progn
(setq teststr (substr str 1 1))
(if (zgx-singlestr-if-letter teststr)
(setq kk 1)
(setq kk 2)
)
(setq mm (+ mm kk))
(setq str (substr str (1+ kk)))
)
)
)
(setq str1 str)
(repeat n
(if (and
str
(/= "" str)
)
(progn
(setq teststr (substr str 1 1))
(if (zgx-singlestr-if-letter teststr)
(setq kk 1)
(setq kk 2)
)
(setq nn (+ nn kk))
(setq str (substr str (1+ kk)))
)
)
)
(if (> n 0)
(substr str1 1 nn)
(substr str1 1)
)
)
)
) |
|