明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2145|回复: 2

[求助]急!字符串的分割问题!

[复制链接]
发表于 2010-1-27 13:59:00 | 显示全部楼层 |阅读模式

如果我又这么一个字符串"0001,test,测试,テスト",怎样才能根据逗号分隔符找出我需要的字符串。

例如如何找出"test"。

不要用substr这个操作符,因为这样的话,我得指定固定的长度和起始位置了。

大家帮帮忙,先谢谢了!

发表于 2010-1-27 14:37:00 | 显示全部楼层

  ;;++++++++++++++++++
  ;;  parser by CAB 
  ;;++++++++++++++++++
  (defun sparser (str delim / ptr lst)
    (while (setq ptr (vl-string-search delim str))
      (setq lst (cons (substr str 1 ptr) lst))
      (setq str (substr str (+ ptr 2)))
    )
    (reverse (cons str lst))
  )


_$ (sparser "12,3,4,,5,6," ",")
("12" "3" "4" "" "5" "6" "")
_$ (vl-remove "" (sphraser "12,3,4,,5,6," ","))
("12" "3" "4" "5" "6")

info:
Http://discussion.autodesk.com/forums/thread.jspa?threadID=759125&tstart=0

 楼主| 发表于 2010-1-27 15:36:00 | 显示全部楼层
Andyhon发表于2010-1-27 14:37:00  ;;++++++++++++++++++  ;;  parser by CAB    ;;++++++++++++++++++  (defun sparser (str delim / ptr lst)    (while (setq ptr (vl-string

谢谢了!

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-1 23:47 , Processed in 0.156975 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表