EDA365电子工程师网

标题: 求助 rexMatchp 函数的使用!! [打印本页]

作者: ghfghyb    时间: 2013-8-8 16:57
标题: 求助 rexMatchp 函数的使用!!
求助   rexMatchp  函数的使用!!
想要求得以下数据
VCC                  BOTTOM                294.35     *(2225.00 1825.00) to  (2480.00 1770.00)

rexMatchp("^[ A-Z0-9_<>*]+[ ]+[A-Z0-9_]+[ ]+[0-9.]+ *([-0-9.]+ [-0-9.]+)+[ ]+ to + [ ]+([-0-9.]+ [-0-9.]+).$" z_cline)

以上是我写的,不知道哪里不对,,一直没抓出数据!!

请指点一下哪里匹配错了!
作者: deargds    时间: 2013-8-8 18:22
rexMatchp为正则匹配检查,参考以下代码,测试通过
  1.         str = "VCC  BOTTOM  294.35 *(2225.00 1825.00) to  (2480.00 1770.00)"
  2.         rexCompile("\\([A-Za-z]*\\)[ ]+\\([A-Za-z]*\\)[ ]+\\([-?0-9.]*\\)[ *(]+\\([-?0-9.]*\\)[ ]+\\([-?0-9.]*\\)[) to*(]+\\([-?0-9.]*\\)[ ]+\\([-?0-9.]*\\)")
  3.         rexExecute(str)
  4.         str1 = rexSubstitute("\\1")
  5.         str2 = rexSubstitute("\\2" )
  6.         str3 = rexSubstitute("\\3" )
  7.         str4 = rexSubstitute("\\4" )
  8.         str5 = rexSubstitute("\\5" )
  9.         str6 = rexSubstitute("\\6" )
  10.         str7 = rexSubstitute("\\6" )
  11.         lResult = list(str1 str2 str3 str4 str5 str6 str7)
复制代码

作者: ghfghyb    时间: 2013-8-8 19:10
deargds

rexMatchp为正则匹配检查,参考以下代码,测试通过


大大有点问题!!
以下是我测试用的RPT,他会把一些其余的东西也打印出来!!
(---------------------------------------------------------------------)
(                                                                     )
(    Dangling Line, Via and Antenna Report                            )
(                                                                     )
(    Drawing          : 1.brd                                         )
(    Software Version : 16.3p006                                      )
(    Date/Time        : Thu Aug 08 19:01:01 2013                      )
(                                                                     )
(---------------------------------------------------------------------)


Report methodology:
  - Dangling lines have at least one end not connected.
  - Dangling vias have one or no connection
      - Plus are not a testvia or a thieving via.
  - Antenna vias do not have connections on their start and end layers.
      - Plus they are not a thieving vias.
      - Optionally, VOLTAGE nets, testvias and through vias can be suppressed with
        the environment variable report_antennavia.
      - Section may be suppressed by variable report_noantennavia.
  - In all cases output is suppressed if an object has the OK_DANGLE
    property or is not part of the current partition.




<< Dangling Vias >>
  Net                  Padstack              Location
  --------------------------------------------------------------
  GND                  VIA020D010           (2075.00 1710.00)


<< Antenna Vias >>
  Net                  Padstack              Location
  --------------------------------------------------------------
  GND                  VIA020D010           (2075.00 1710.00)

<< Summary >>
  Total dangling lines:       0
  Total dangling vias:        1
  Total antenna vias:         1

以下是我的代码,我需要抓dline和dvia两种数据!!
试用了你的代码,发现多出了一些东西!!
麻烦再指点一下!!
  1. defun(x_get_dline_list nil
  2.         let((dlineport temp_dline  dlinelist dvialist next_line)
  3.             prog( nil
  4.                 ;        deleteFile("x_temp_dlines.txt")
  5.                         axlShell("reports 'Dangling Lines Report' nographic write x_temp_dlines.txt")
  6.                         when((isFile("x_temp_dlines.txt") == nil)
  7.                             return(nil)
  8.                         )
  9.                         (dlineport = infile("x_temp_dlines.txt"))
  10.                         (dlinelist = nil)
  11.                         (dvialist = nil)
  12.                         temp_dline = nil
  13.                         when(dlineport
  14.                             while( gets(next_line dlineport)
  15.                                         if(index(next_line "Antenna Vias") == nil then
  16.                                        
  17.                                         ;  VCC                  BOTTOM                294.35     *(2225.00 1825.00) to  (2480.00 1770.00)
  18.                                         ;[ A-Z0-9]+[ ]+[A-Z0-9]+[ ]+[0-9.]+[ ]+[*(][-0-9.]+ [-0-9]+[) to (]+[-0-9.]+ [-0-9.]+).$
  19.                                 ;        when( rexMatchp("^[ A-Z0-9]+[ ]+[A-Z0-9]+[ ]+[0-9.]+[ ]+[*(][-0-9.]+ [-0-9]+[) to (]+[-0-9.]+ [-0-9.]+).$ " next_line )
  20.                                         when( rexMatchp("\\([A-Za-z]*\\)[ ]+\\([A-Za-z]*\\)[ ]+\\([-?0-9.]*\\)[ *(]+\\([-?0-9.]*\\)[ ]+\\([-?0-9.]*\\)[) to*(]+\\([-?0-9.]*\\)[ ]+\\([-?0-9.]*\\)" next_line )
  21.                                                 temp_dline = buildString( parseString(next_line) "  ")
  22.                                             rexCompile("(")
  23.                                             temp_dline = rexReplace(temp_dline "" 1)
  24.                                                 rexCompile(")")
  25.                                             temp_dline = rexReplace(temp_dline "" 1)
  26.                                                 dlinelist = cons( temp_dline dlinelist )

  27.                                         );end when
  28.                                        
  29.                                         ;        GND                  VIA020D010           (2075.00 1710.00)
  30.                                         when( rexMatchp("^[ A-Z0-9_<>*]+[ ]+[A-Z0-9_]+[ ]+([-0-9.]+ [-0-9.]+).$" next_line )
  31.                                             temp_dline = buildString( parseString(next_line) "  ")
  32.                                             rexCompile("(")
  33.                                             temp_dline = rexReplace(temp_dline "" 1)
  34.                                                 rexCompile(")")
  35.                                             temp_dline = rexReplace(temp_dline "" 1)
  36.                                                 dvialist = cons( temp_dline dvialist )
  37.                                                 );end when
  38.                                                
  39.                                                
  40.                                        
  41.                                         else close(dlineport)
  42.                                         );end when
  43.                                 ;        printf("%L \n" dvialist)
  44.                                        
  45.                                 )
  46.                            
  47.                         ;        printf("%L \n" dlinelist)
  48.                                 printf("%L \n" dvialist)
  49.                                 close(dlineport)
  50.                         )
  51.                        
  52.                 ;        deleteFile("x_temp_dlines.txt")
  53.                         return(list(dlinelist dvialist))
  54.                 ;        return(list(dlinelist dvialist))
  55.             )
  56.         )
  57. )
  58.        



  59. axlCmdRegister("zz1" 'x_get_dline_list ?cmdType "general")
复制代码

作者: ghfghyb    时间: 2013-8-8 19:31
哈哈,找到原因了,多了一个*

rexMatchp("^[ A-Za-z]*[ ]+[A-Za-z]*[ ]+[-?0-9.]*[ *(]+[-?0-9.]*[ ]+[-?0-9.]*[) to (]+[-?0-9.]*[ ]+[-?0-9.]*[)].$" next_line)
改成这样就可以了!!嘿嘿!!
谢谢大大们的指点!




欢迎光临 EDA365电子工程师网 (https://bbs.elecnest.cn/) Powered by Discuz! X3.2