Hi,
i need to parse dhcp leases table with php regex. but the thing is it contains different characters used in regex too.
here is sample output
lease 172.17.2.3 {
starts 4 2009/07/16 11:54:39;
ends 4 2009/07/16 12:54:39;
cltt 4 2009/07/16 11:54:39;
binding state active;
next binding state free;
hardware ethernet 00:50:56:c0:00:01;
uid "\001\000PV\300\000\001";
client-hostname "Yasin-PC";
}
lease 172.17.2.3 {
starts 4 2009/07/16 12:24:39;
ends 4 2009/07/16 13:24:39;
cltt 4 2009/07/16 12:24:39;
binding state active;
next binding state free;
hardware ethernet 00:50:56:c0:00:01;
uid "\001\000PV\300\000\001";
client-hostname "Yasin-PC";
}
lease 172.17.2.3 {
starts 4 2009/07/16 12:54:39;
ends 4 2009/07/16 13:54:39;
cltt 4 2009/07/16 12:54:39;
binding state active;
next binding state free;
hardware ethernet 00:50:56:c0:00:01;
uid "\001\000PV\300\000\001";
client-hostname "Yasin-PC";
}
problem is i want to assign whole table into an array indexed with ip addresses after lease ..XX.XX.XX.XX {... & there will be duplicate keys but values will be different so i need to solve that to...
what would you advice me to save my time to build a good regex for this ? posix or pcre or reading line by line ?
& i can not be sure about target leases table will be all in the same format. maybe some times a few more lines i expect.