IMHO, you have many unneeded operations, e.g. :
1. You write the matches to string first (not directly to an array) :
2. Then split the string to array :
3. Then :
a. join the array again to become a string
b. remove "interface" word
c. split again the string into an array
So number of operations are :
[1] String concatenation
[2] Split
[3] Join
[4] Replace string
[5] Split
Here is my proposed code (still in the form as a sub, you can convert them to a function later) :
Only one operation needed, that is assigning the matches to an array from these lines :
The pattern itself is :
Pattern = "^interface (Vlan[^\r\n]+)"
the word "interface" is put outside brackets, only Vlan.... that put inside brackets, so this became a submatch, which we can retrieve from v2.SubMatches(0)
Bookmarks