EDA365电子论坛网

标题: 【以解决】请问怎么匹配 "2.3001 MM",并且提取2.3001和MM [打印本页]

作者: 361553894    时间: 2016-10-24 10:36
标题: 【以解决】请问怎么匹配 "2.3001 MM",并且提取2.3001和MM
本帖最后由 361553894 于 2016-10-25 12:08 编辑

rexMatchp("^[0-9]*[.][0-9]+ [a-zA-Z]*$" "2.3001 MM")是能匹配的
现在想用rexCompile、rexExecute匹配,rexSubstitute提取,即

  1. rexCompile("\\([0-9]*[.][0-9]+\\) \\([a-zA-Z]*\\)")
  2. when(rexExecute("2.3001 MM")
  3.    height_max_value = rexSubstitute(“\\1”)
  4.    height_max_unit = rexSubstitute(“\\2”)
  5. )
复制代码
但是匹配不上
丢代码上来好困难啊。。总是因为转义字符变了(上面引号改成中文引号了)


作者: hoo    时间: 2016-10-24 14:07
  1. Skill > rexCompile("\\([0-9.]+\\) \\([a-zA-Z]+\\)")
  2. t
  3. Skill > rexExecute("2.3001 MM")
  4. t
  5. Skill > height_max_value = rexSubstitute("\\1")
  6. "2.3001"
  7. Skill > height_max_unit = rexSubstitute("\\2")
  8. "MM"
复制代码

作者: 361553894    时间: 2016-10-25 12:08
hoo 发表于 2016-10-24 14:07

非常感谢

作者: wcjcn    时间: 2017-6-9 10:27
非常感谢。。。。。




欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) Powered by Discuz! X3.2