找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 684|回复: 6
打印 上一主题 下一主题

对着练习自己写了一个测试,发现没输出,请大大们帮忙看一下!!

[复制链接]

47

主题

266

帖子

2730

积分

四级会员(40)

Rank: 4Rank: 4Rank: 4Rank: 4

积分
2730
跳转到指定楼层
1#
发表于 2012-7-18 21:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您!

您需要 登录 才可以下载或查看,没有帐号?注册

x
lStr = list(" Power TOP *(7710.00 -1865.00) to *(6705.00 -1615.00)" "GND BOTTOM *(7890.00 -1774.00) to *(6575.00 -2045.00)")
rexCompile( "^[A-Z0-p_]+[ ]+[A-Z0-9-]+[ ]+([-0-9.]+[-0-9.])+[A-Z]+([-0-9.]+[-0-9.])")
; \\(...\\) 结构表示匹配的部分将可以用19提取出来
; [A-Z]表示匹配A~Z的字符,+表示至少有一个这样的字符
foreach( item lStr
  when( rexExecute( item )
      str1 = rexSubstitute( "^[1]" )
      str2 = rexSubstitute( "^[2]" )
      str3 = rexSubstitute( "^[3]" )
          str4 = rexSubstitute( "^[4]" )
          str5 = rexSubstitute( "^[5]" )
          str6 = rexSubstitute( "^[6]" )
        printf("%s<->%s<->%s<->%s<->%s<->%s\n" str1 str2 str3 str4 str5 str6)
  )
);
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏1 支持!支持! 反对!反对!

57

主题

1857

帖子

7919

积分

六级会员(60)

Rank: 6Rank: 6

积分
7919
2#
发表于 2012-7-19 13:47 | 只看该作者
上面看起來有點複雜,可以改用下列看看,是不是你要的結果
lStr = list("Power TOP *(7710.00 -1865.00) to *(6705.00 -1615.00)" "GND BOTTOM *(7890.00 -1774.00) to *(6575.00 -2045.00)")
foreach( item lStr
  tTemp = parseString(item " *()")
  str1 = nthelem(1 tTemp)
  str2 = nthelem(2 tTemp)
  str3 = nthelem(3 tTemp)
  str4 = nthelem(4 tTemp)
  str5 = nthelem(6 tTemp)
  str6 = nthelem(7 tTemp)
  printf("%s<->%s<->%s<->%s<->%s<->%s\n" str1 str2 str3 str4 str5 str6)
)

57

主题

1857

帖子

7919

积分

六级会员(60)

Rank: 6Rank: 6

积分
7919
3#
发表于 2012-7-19 15:25 | 只看该作者
本帖最后由 XYX365 于 2012-7-20 14:58 编辑

還有一種方法
lStr = list("Power TOP *(7710.00 -1865.00) to *(6705.00 -1615.00)" "GND BOTTOM *(7890.00 -1774.00) to *(6575.00 -2045.00)")
rexCompile("\\([A-Za-z]*\\)[ ]+\\([A-Za-z]*\\)[ *(]+\\([-?0-9.]*\\)[ ]+\\([-?0-9.]*\\)[) to*(]+\\([-?0-9.]*\\)[ ]+\\([-?0-9.]*\\)")
或是改為rexCompile("\\([A-Za-z]*\\) \\([A-Za-z]*\\)[ *(]+\\([0-9.-]*\\) \\([0-9.-]*\\)[) to*]+(\\([0-9.-]*\\) \\([0-9.-]*\\)")也可以


foreach( item lStr
  when( rexExecute( item )
      str1 = rexSubstitute("\\1")
      str2 = rexSubstitute("\\2" )
      str3 = rexSubstitute("\\3" )
      str4 = rexSubstitute("\\4" )
      str5 = rexSubstitute("\\5" )
      str6 = rexSubstitute("\\6" )
      printf("%s<->%s<->%s<->%s<->%s<->%s\n" str1 str2 str3 str4 str5 str6)
  )
);

47

主题

266

帖子

2730

积分

四级会员(40)

Rank: 4Rank: 4Rank: 4Rank: 4

积分
2730
4#
 楼主| 发表于 2012-7-19 20:58 | 只看该作者
XYX365 3# 发表于 5 小时前

请教一个问题,,parseString,,nthelem,,这两个代码是实现什么功能啊!!

47

主题

266

帖子

2730

积分

四级会员(40)

Rank: 4Rank: 4Rank: 4Rank: 4

积分
2730
5#
 楼主| 发表于 2012-7-19 21:01 | 只看该作者
看了一下资料了,,明白什么意思,,看样子,还是基础太差了,,我还是从资料开始看吧!!

Selecting an Indexed Element from a List (nthelem)
nthelem returns an indexed element of a list, assuming a one-based index. Thus
nthelem(1 l_list) is the same as car(l_list).
nthelem( 1 '( a b c ) ) => a
z = '( 1 2 3 )
nthelem( 2 z ) => 2

5

主题

77

帖子

178

积分

二级会员(20)

Rank: 2Rank: 2

积分
178
6#
发表于 2012-7-19 22:32 | 只看该作者
学习了,看来我也要基础学习了

53

主题

647

帖子

1460

积分

四级会员(40)

Rank: 4Rank: 4Rank: 4Rank: 4

积分
1460
7#
发表于 2012-7-20 00:07 | 只看该作者
akndk
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

巢课

技术风云榜

关于我们|手机版|EDA365 ( 粤ICP备18020198号 )

GMT+8, 2025-2-24 20:24 , Processed in 0.065204 second(s), 32 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

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