我有这样一个表格,结构很乱。。没行列标题,直接就是一行行的数据,
每行中 都有这样的字符:cellRef,但是每行中不一定有几个,所以说每行的数据长度都不一致如下为一行数据:a3b,1 ce22 dd11 cellRef 123 dk 3i yad ii1 cellRef 456 caku8 cellRef 789我想要提取 cellRef 后面的数字,如cellRef 123,我要得到123,或者是cellRef 123,都可以,因为我要知道这些数据中,用到了哪些cellRef,如刚才找到的123已经被使用了。同理,第一行数据中,我提取出了123,456,789。
我打算把这些数据放到一列中,以便于查看。看似很复杂呀,感觉就好比从一篇文章中,提取所有的句号后面的第一个字一样
大侠指点一下吧 万分感谢哈!!!最好是能用excel实现,我对VBA不熟悉

解决方案 »

  1.   

    FILE *f;
    int v;
    f=fopen("...","r");
    while (1) {
     if (feof(f)) break;
     if (1==fscanf(f,"cellRef %d",&v)) {
      printf("%d\n",v);
     } else {
      fscanf(f,"%*c");
     }
    }
    fclose(f);
      

  2.   

    他对vba都不熟悉,用c语言+文件指针太勉为其难了。'This code was generated by "RegTestTool v1.1.30", please call the sub TestReg.
    Private Sub TestReg()
        Dim strData As String
        Dim reg As Object
        Dim matchs As Object, match As Object    strData = "a3b,1 ce22 dd11 cellRef 123 dk 3i yad ii1 cellRef 456 caku8 cellRef 789"    Set reg = CreateObject("vbscript.regExp")
        reg.Global = True
        reg.IgnoreCase = True
        reg.MultiLine = True
        reg.Pattern = "cellRef (\d+)"
        Set matchs = reg.Execute(strData)
        For Each match In matchs
            Debug.Print match.SubMatches(0)
        Next
    End Sub