.net regular expression to parse a file
Posted on 2015-01-07
I need to parse a configuration file to parse a file similar to this:
snmp-server community "xxxx"
no ip address
no untagged 1-22,Trk1
ip address 220.127.116.11 255.255.254.0
I want to extract all the ports that are tagged to vlan 32. Here is what I have so far, but it doesn't group all the ports. I only get some of them.
vlan 32\s\n\s*name "cheese".*\n\s*ip address.*\n(?:\n?\s*tagged (?:(?:(\d\d?-\d\d?)|(\d\d)|Trk\d|(\d)),?)*)
I am using powershell to read the file and match:
[IO.File]::ReadAllText($_.FullName) -imatch $regex
How do I create a group for each port so it will output these groups?