Reg Ex Question

Ok I am having a blank moment here when I am trying to search vertically for patterns vs. horizontal on a line.

Source:
System has 4 fan modules
Mod # of Fans Model Serial Number


1 1 FAN-7000-F N/A
2 1 FAN-7000-F N/A
3 1 FAN-7000-F N/A
System has 53 ports

For this example I need to match only the FAN-7000-F in each line in that third model Column. What pattern would be best for this?

Thank you in advance!!

I have found the (?xm) pattern that ignores comments and white spaces. Am I on the right track?

(?xm)
^
(?:
.
(?=.*+
)
)

This for example matches every first letter/number in my output. I am getting close hopefully :slight_smile:

based on that small example, ^\d+\s+\d+\s+(.+)\s should capture everything between the 2nd and 3rd whitespace groups.

Thanks for the reply Scott. Your pattern didn’t achieve that, but I can’t really match between white spaces as different switches will output the same results but in a different order. (Above was a small snippet from a large output)

Thanks again!

What do we know for sure about the text you want to capture? Does it always start with “FAN”? Is it always some combination of letters and numbers?

From a column perspective anything under that column title of “Model” for example minus the -----
:slight_smile: thank you Kem!

I am sure all of Arista’s models do begin with FAN- but can we assume not just in case of future changes? (I already have a pattern I made that looks for the FAN-) :wink: Thanks again!!

How are the columns delineated? Are those tabs or spaces?

Spaces.

I would use InStr to find the start of the Model column then use Right on each subsequent line and NthField to break off the first word.

Ah thank you Kem! I will try that.