Reputation: 379
I have following string
> show box detail
2 boxes:
1) Box ID: 1
IP: 127.0.0.1
Interface: 1/1
Priority: 31
2) Box ID: 2
IP: 192.68.1.1
Interface: 1/2
Priority: 31
How to get BOX ID from above string in perl? The number of boxes here can vary . So based on the number of boxes "n", how to extract box Ids if the show box detail can go upto n nodes in the same format ?
Upvotes: 0
Views: 185
Reputation: 385506
my @ids = $string =~ /Box ID: ([0-9]+)/g;
More restrictive:
my @ids = $string =~ /^[0-9]+\) Box ID: ([0-9]+)$/mg;
Upvotes: 2