Thanks. I currently do this:
For zz = LBound(rSRCDataArray) To UBound(rSRCDataArray)
rSRCDataArray(zz) = "!" & rSRCDataArray(zz) & "!" ' wrap delimiters to cure false matches ( since I do not know how to do RegEx yet)
' For example, searching for "vrf " will find "vrf " and " vrf "
' "!vrf " will not find "! vrf "
' " encapsulation ###" will find second-dot1q entries if present
' " encapsulation ###!" will find only the encap without second-dot1q
Next zz
As you might guess, I'm using this to open a "show run" router dump. I've already dealt with the limitation of Application.MAtch if my text file is too big.
Here is how I find the correct interface (which is supposed to match a cell on my worksheet:
Range("B2").Select
rSRCIntArray = Filter(rSRCDataArray, "!interface " & ActiveCell.Value & "!") ' Match data array on specified interface
If Not UBound(rSRCIntArray) = 0 Then
Beep
Call MarkPaleRED
MsgBox "CRITICAL ERROR!" & vbCrLf & "interface " & ActiveCell.Value & vbCrLf & " not found in data!"
End
Else
Call MarkPaleGREEN
End If
If you know anything about Cisco routers, you notice that looking for the interface the way I do with the bangs ("!") is silly, but for other searches I'm being consistent.
Plus, for other things (like vrf or ip route, etc) I would use the bangs to help search for proper start/end of line hits.
In BGP code, I might looks for "! neighbor " which is different than "! neighbor".
In a static route, I would Filter for a gateway IP at the end of a line, similar to " 42.68.101.12!".
If I were looking for a matching neighbor, I'd Filter for "! neighbor 42.68.101.12" or "! neighbor 42.68.101.12".
For something like an "ip route" I Filter using the IP ending with a bang, then use a For/Next on LBound/UBound on the Filter results to match lines that start "!ip route" (and if looking for public routes, skipping "!ip route vrf".
Instead of using ReDim, I tend to Join and array into a delimited string, the Split it back to a correctly sized array.
Bookmarks