#1
|
|||
|
|||
Try to match multiple Mac addresses
I try to use below RegEx pattern and Script to match all the mac addresses , but every time the script only match the First Mac address, it doesn't not match the Second Mac address.
Macs.count (see below) is always 1. Code:
Source Data: 160k1flSW81#sh mac add int g1/0/2 Mac Address Table ------------------------------------------- Vlan Mac Address Type Ports ---- ----------- -------- ----- 54 1803.733b.f4fb STATIC Gi1/0/2 380 001e.f729.8626 STATIC Gi1/0/2 Total Mac Addresses for this criterion: 2 Code:
Set MMC = New RegExp MMC.Pattern = "\d+\s+([0-9a-f]{4}\.[0-9a-f]{4}\.[0-9a-f]{4})\s+\S+\s+\S+" MMC.IgnoreCase = True strResultsMac = crt.Screen.ReadString("#") If MMC.Test(strResultsMac) <> True Then ws.Cells(row, 3).Value = "No Mac detected" Else Set Macs = MMC.Execute(strResultsMac) MsgBox "Macs.count=" & Macs.count Temp = "" For Each Mac In Macs Temp = Temp & Mac.SubMatches(0) & Chr(10) Next ws.Cells(row, 3).Value = Temp --> only see just "1" Mac address Last edited by mybox65; 04-25-2014 at 10:04 AM. |
#2
|
||||
|
||||
Quote:
See the attached screenshot of Microsoft's VBScript help manual for information on how to set the Global property of the RegExp object to True so it will return all matches found. If there are other questions about VBScript natives, Microsoft's VBScript help can be downloaded and installed locally to your machine, and is a good resource you can use to find answers. --Jake
__________________
Jake Devenport VanDyke Software Technical Support YouTube Channel: https://www.youtube.com/vandykesoftware Email: support@vandyke.com Web: https://www.vandyke.com/support |
#3
|
|||
|
|||
Quote:
Hi Jake, Thank you very much !!! I really like your team and product. Regards, Mybox |
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|