VBA--正则使用

Sub 正则()
Set REG = CreateObject("VBSCRIPT.REGEXP")
Dim STR As String, S

X = WorksheetFunction.CountA(Worksheets("sheet1").Range("A:A"))
  For I = 1 To X
       STR = Cells(I, 1).Text
          With REG
         .Global = True
         .Pattern = "EUtranCellTDD=+\w+\-\w+\-\d+|EUtranCellFDD=\w+\-\w+\-\d+"
         
        Set S = .Execute(STR)
          For Each M In S
             Y3 = Y3 + 1
            ReDim BR(1 To Y3)
            
            BR(Y3) = M
            l = l & BR(Y3)
   
           
           Next
           Cells(I, 2) = l
           Y3 = 0
           l = ""
          End With
    
      
      
    STR2 = Cells(I, 1).Text
        With REG
        .Global = True
       .Pattern = "b2Thr1RsrpGeranFreqQciOffset = \-\d+|b2Thr1RsrpGeranFreqQciOffset = \d+|b2Thr2GeranFreqQciOffset = \d+|QciProfilePredefined=qci\d+"
             
         Set X2 = .Execute(STR2)
           
          For Each MT2 In X2
               Y2 = Y2 + 1
               
               ReDim BR(1 To Y2)
               BR(Y2) = MT2  '把字符存入数组
               
             
                O = O & BR(Y2)
            Next
    
             'Cells(I, 13) = Cells(3, 13) & "|" & BR(Y)
               
                 Cells(I, 3) = O
                 O = ""
                 Y2 = 0
             End With
      Next
End Sub
上一篇:雷林鹏分享:Apache POI单元格/Cells


下一篇:js从table标签中取数据