fork download
  1. <?php
  2.  
  3. $text = <<<TEXT
  4. Changed the current scope context to 192.25.200.0 scope.
  5.  
  6. Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP
  7. ============================================================================================
  8. IP Address - Subnet Mask - Unique ID - Lease Expires -Type -Name
  9. ============================================================================================
  10.  
  11. 192.25.200.4 - 255.255.255.192- 64-9e-f3-b3-81-d3 -01/08/2018 17:07:46 -D- BH1-WAP-01.local
  12. 192.25.200.5 - 255.255.255.192- 50-57-a8-30-11-f6 -01/08/2018 16:24:59 -D- BH1-WAP-03.local
  13. 192.25.200.6 - 255.255.255.192- f0-f7-55-df-c4-ff -01/08/2018 16:45:04 -D- BH1-WAP-02.local
  14. 192.25.200.7 - 255.255.255.192- 00-23-24-bb-ce-83 -04/08/2018 10:55:00 -D- CESTA1703043.LOCAL
  15.  
  16. No of Clients(version 4): 4 in the Scope : 192.25.200.0.
  17.  
  18. Command completed successfully.
  19.  
  20. Changed the current scope context to 192.25.200.64 scope.
  21.  
  22. Type : N - NONE, D - DHCP B - BOOTP, U - UNSPECIFIED, R - RESERVATION IP
  23. ============================================================================================
  24. IP Address - Subnet Mask - Unique ID - Lease Expires -Type -Name
  25. ============================================================================================
  26.  
  27. 192.25.200.68 - 255.255.255.192- 28-94-0f-05-ac-6c -01/08/2018 03:14:46 -D- WAP-C12-01-1047.local
  28.  
  29. No of Clients(version 4): 1 in the Scope : 192.25.200.64.
  30.  
  31. Command completed successfully.
  32. Changed the current scope context to 192.28.211.0 scope.
  33. 192.28.211.27 - 255.255.255.0 -00-0a-13-00-00-00-00- NEVER EXPIRES -U- CFCameraNearlockers
  34.  
  35. Changed the current scope context to 192.28.194.0 scope.
  36. 192.28.194.254 - 255.255.255.0 -00-48-32-95-85 - INACTIVE -N- bms
  37. TEXT;
  38.  
  39. $reg = '~^(\d{1,3}(?:\.\d{1,3}){3})\s*-\s*((?1))\s*-\s*((?:[0-9A-Fa-f]{2}[:-]){3,6}[0-9A-Fa-f]{2})\s*-\s*(\d\d/\d\d/\d{4}\s\d\d(?::\d\d){2}|NEVER EXPIRES|INACTIVE)\s*-\s*(\w)\s*-\s*(.*)$~m';
  40. $arr = [];
  41. if (preg_match_all($reg, $text, $ms, PREG_SET_ORDER, 0)) {
  42. foreach ($ms as $m) {
  43. $arr[] = $m[1] . ' ~ ' . $m[2] . ' ~ ' . $m[3] . ' ~ ' . $m[4] . ' ~ ' . $m[5] . ' ~ ' . $m[6];
  44. }
  45. }
  46. print_r($arr);
Success #stdin #stdout 0.02s 23748KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 192.25.200.4 ~ 255.255.255.192 ~ 64-9e-f3-b3-81-d3 ~ 01/08/2018 17:07:46 ~ D ~ BH1-WAP-01.local
    [1] => 192.25.200.5 ~ 255.255.255.192 ~ 50-57-a8-30-11-f6 ~ 01/08/2018 16:24:59 ~ D ~ BH1-WAP-03.local
    [2] => 192.25.200.6 ~ 255.255.255.192 ~ f0-f7-55-df-c4-ff ~ 01/08/2018 16:45:04 ~ D ~ BH1-WAP-02.local
    [3] => 192.25.200.7 ~ 255.255.255.192 ~ 00-23-24-bb-ce-83 ~ 04/08/2018 10:55:00 ~ D ~ CESTA1703043.LOCAL
    [4] => 192.25.200.68 ~ 255.255.255.192 ~ 28-94-0f-05-ac-6c ~ 01/08/2018 03:14:46 ~ D ~ WAP-C12-01-1047.local
    [5] => 192.28.211.27 ~ 255.255.255.0 ~ 00-0a-13-00-00-00-00 ~ NEVER EXPIRES ~ U ~ CFCameraNearlockers
    [6] => 192.28.194.254 ~ 255.255.255.0 ~ 00-48-32-95-85 ~ INACTIVE ~ N ~ bms
)