- Dim str,Rs,Match
- str = "a100_b100_a100_01" & vbCrLf & "b100_a100_b100_02" & _
- vbcrlf & "c100_03" & vbCrLf & "c200_a100_c100_04" & _
- vbCrLf & "a100_c200_05" & vbCrLf & "d100_06" & _
- vbCrLf & "a100_07"
- Set Rs = New RegExp
- Rs.Global = True
- Rs.IgnoreCase = True
- Rs.Pattern = "(a100).+"
- Set Match = Rs.Execute(str)
- For Each m In Match
- MsgBox m.Value
- Next
复制代码 上面这段代码查找所有有"a_100"的字符行并显示。
现在我只想查找每行以"a_100"开头的行,该怎么改匹配模式?
我曾试过将匹配模式改为Rs.Pattern = "^(a100).+",但是好像不管用。 |