TextFSM Logic - Avoid Capturing Same Data Twice
I'm trying to record optics light readings off a cisco RFGW. The issue I'm facing is that because of the way the data is displayed I capture the Physical interface twice and the d
Solution 1:
I decomposed a bit. What you want is:
- Match the interface:
(\w+\d\/\d+)
- After a few spaces, match the transmit power:
(-?\d\.\d+)
(use of?
is preferable here as you don't want multiple following-
) - Find in the following text the same interface again:
(?=.*\1)
- That one followed by the received power (same as 2.)
If you assemble it all, you get:
(\w+\d+\/\d+)\s+(-?\d+\.\d+)(?=.+\1\s+(-?\d+\.\d+))
^
Capturing in the lookahead, that way relevant data is captured, but not eaten by the engine, which would prevent following matches.
See the demo.
Post a Comment for "TextFSM Logic - Avoid Capturing Same Data Twice"