fork download
  1. <?php
  2.  
  3. // your code goes here
  4. $var = '192.168.1.1 | SUCCESS => { "architecture": "amd64", "lsbdistcodename": "wheezy", "lsbdistdescription": "Debian GNU/Linux 7.9 (wheezy)", "lsbdistid": "Debian", "lsbdistrelease": "7.9", "lsbmajdistrelease": "7", "lsbminordistrelease": "9", "memoryfree": "653.05 MB", "memoryfree_mb": "653.05", "memorysize": "1002.94 MB", "memorysize_mb": "1002.94", "operatingsystem": "Debian", "operatingsystemmajrelease": "7", "operatingsystemrelease": "7.9", "os": { "family": "Debian", "lsb": { "distcodename": "wheezy", "distdescription": "Debian GNU/Linux 7.9 (wheezy)", "distid": "Debian", "distrelease": "7.9", "majdistrelease": "7", "minordistrelease": "9" }, "name": "Debian", "release": { "full": "7.9", "major": "7", "minor": "9" } }, "osfamily": "Debian", "partitions": { "sda1": { "filesystem": "LVM2_member", "size": "41938944" } }, "physicalprocessorcount": 1, "processor0": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz", "processorcount": 1, "processors": { "count": 1, "models": [ "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz" ], "physicalcount": 1 }, "timezone": "EET", "uniqueid": "007f0101", "uptime": "360 days", "uptime_days": 360, "uptime_hours": 8644, "uptime_seconds": 31119057, "virtual": "vmware"}192.168.1.1 | SUCCESS => { "architecture": "x86_64", "is_virtual": true, "kernel": "Linux", "kernelmajversion": "3.10", "kernelrelease": "3.10.0-514.2.2.el7.x86_64", "kernelversion": "3.10.0", "macaddress": "00:50:56:b1:c6:49", "macaddress_eno16777984": "00:50:56:b1:c6:49", "memoryfree": "1.58 GB", "memoryfree_mb": "1617.09", "memorysize": "1.80 GB", "operatingsystemmajrelease": "7", "operatingsystemrelease": "7.3.1611", "os": { "family": "RedHat", "name": "CentOS", "release": { "full": "7.3.1611", "major": "7", "minor": "3" } }, "osfamily": "RedHat", "partitions": { "sda1": { "filesystem": "xfs", "mount": "/boot", "size": "1024000", "uuid": "e50a313f-98fa-4d7d-a40d-eb0c3b5f3ef5" }, "sda2": { "filesystem": "LVM2_member", "size": "30423040" } }, "path": "/usr/local/bin:/usr/bin", "physicalprocessorcount": 1, "processor0": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz", "processorcount": 1, "processors": { "count": 1, "models": [ "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz" ], "physicalcount": 1 }, "timezone": "EET", "uniqueid": "44d40600", "uptime": "87 days", "uptime_days": 87, "uptime_hours": 2094, "uptime_seconds": 7539660, "virtual": "vmware"';
  5.  
  6. $pattern = '/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(?:\/\d{2})?/';
  7. $replacement = '';
  8. $result = preg_replace($pattern, $replacement, $var);
  9. echo "$result".PHP_EOL;
  10. $arr = explode("| SUCCESS =>", $result);
  11.  
  12. print_r($arr);
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
 | SUCCESS => {    "architecture": "amd64",      "lsbdistcodename": "wheezy",    "lsbdistdescription": "Debian GNU/Linux 7.9 (wheezy)",    "lsbdistid": "Debian",    "lsbdistrelease": "7.9",    "lsbmajdistrelease": "7",    "lsbminordistrelease": "9",     "memoryfree": "653.05 MB",    "memoryfree_mb": "653.05",    "memorysize": "1002.94 MB",    "memorysize_mb": "1002.94",     "operatingsystem": "Debian",    "operatingsystemmajrelease": "7",    "operatingsystemrelease": "7.9",    "os": {        "family": "Debian",        "lsb": {            "distcodename": "wheezy",            "distdescription": "Debian GNU/Linux 7.9 (wheezy)",            "distid": "Debian",            "distrelease": "7.9",            "majdistrelease": "7",            "minordistrelease": "9"        },        "name": "Debian",        "release": {            "full": "7.9",            "major": "7",            "minor": "9"        }    },    "osfamily": "Debian",    "partitions": {        "sda1": {            "filesystem": "LVM2_member",            "size": "41938944"        }    },     "physicalprocessorcount": 1,    "processor0": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz",    "processorcount": 1,    "processors": {        "count": 1,        "models": [            "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz"        ],        "physicalcount": 1     },    "timezone": "EET",    "uniqueid": "007f0101",    "uptime": "360 days",    "uptime_days": 360,    "uptime_hours": 8644,    "uptime_seconds": 31119057,    "virtual": "vmware"} | SUCCESS => {    "architecture": "x86_64",       "is_virtual": true,    "kernel": "Linux",    "kernelmajversion": "3.10",    "kernelrelease": "3.10.0-514.2.2.el7.x86_64",    "kernelversion": "3.10.0",    "macaddress": "00:50:56:b1:c6:49",    "macaddress_eno16777984": "00:50:56:b1:c6:49",    "memoryfree": "1.58 GB",    "memoryfree_mb": "1617.09",    "memorysize": "1.80 GB",     "operatingsystemmajrelease": "7",    "operatingsystemrelease": "7.3.1611",    "os": {        "family": "RedHat",        "name": "CentOS",        "release": {            "full": "7.3.1611",            "major": "7",            "minor": "3"        }    },    "osfamily": "RedHat",    "partitions": {        "sda1": {            "filesystem": "xfs",            "mount": "/boot",            "size": "1024000",            "uuid": "e50a313f-98fa-4d7d-a40d-eb0c3b5f3ef5"        },        "sda2": {            "filesystem": "LVM2_member",            "size": "30423040"        }    },    "path": "/usr/local/bin:/usr/bin",    "physicalprocessorcount": 1,    "processor0": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz",    "processorcount": 1,    "processors": {        "count": 1,        "models": [            "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz"        ],        "physicalcount": 1    },     "timezone": "EET",    "uniqueid": "44d40600",    "uptime": "87 days",    "uptime_days": 87,    "uptime_hours": 2094,    "uptime_seconds": 7539660,    "virtual": "vmware"
Array
(
    [0] =>  
    [1] =>  {    "architecture": "amd64",      "lsbdistcodename": "wheezy",    "lsbdistdescription": "Debian GNU/Linux 7.9 (wheezy)",    "lsbdistid": "Debian",    "lsbdistrelease": "7.9",    "lsbmajdistrelease": "7",    "lsbminordistrelease": "9",     "memoryfree": "653.05 MB",    "memoryfree_mb": "653.05",    "memorysize": "1002.94 MB",    "memorysize_mb": "1002.94",     "operatingsystem": "Debian",    "operatingsystemmajrelease": "7",    "operatingsystemrelease": "7.9",    "os": {        "family": "Debian",        "lsb": {            "distcodename": "wheezy",            "distdescription": "Debian GNU/Linux 7.9 (wheezy)",            "distid": "Debian",            "distrelease": "7.9",            "majdistrelease": "7",            "minordistrelease": "9"        },        "name": "Debian",        "release": {            "full": "7.9",            "major": "7",            "minor": "9"        }    },    "osfamily": "Debian",    "partitions": {        "sda1": {            "filesystem": "LVM2_member",            "size": "41938944"        }    },     "physicalprocessorcount": 1,    "processor0": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz",    "processorcount": 1,    "processors": {        "count": 1,        "models": [            "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz"        ],        "physicalcount": 1     },    "timezone": "EET",    "uniqueid": "007f0101",    "uptime": "360 days",    "uptime_days": 360,    "uptime_hours": 8644,    "uptime_seconds": 31119057,    "virtual": "vmware"} 
    [2] =>  {    "architecture": "x86_64",       "is_virtual": true,    "kernel": "Linux",    "kernelmajversion": "3.10",    "kernelrelease": "3.10.0-514.2.2.el7.x86_64",    "kernelversion": "3.10.0",    "macaddress": "00:50:56:b1:c6:49",    "macaddress_eno16777984": "00:50:56:b1:c6:49",    "memoryfree": "1.58 GB",    "memoryfree_mb": "1617.09",    "memorysize": "1.80 GB",     "operatingsystemmajrelease": "7",    "operatingsystemrelease": "7.3.1611",    "os": {        "family": "RedHat",        "name": "CentOS",        "release": {            "full": "7.3.1611",            "major": "7",            "minor": "3"        }    },    "osfamily": "RedHat",    "partitions": {        "sda1": {            "filesystem": "xfs",            "mount": "/boot",            "size": "1024000",            "uuid": "e50a313f-98fa-4d7d-a40d-eb0c3b5f3ef5"        },        "sda2": {            "filesystem": "LVM2_member",            "size": "30423040"        }    },    "path": "/usr/local/bin:/usr/bin",    "physicalprocessorcount": 1,    "processor0": "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz",    "processorcount": 1,    "processors": {        "count": 1,        "models": [            "Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz"        ],        "physicalcount": 1    },     "timezone": "EET",    "uniqueid": "44d40600",    "uptime": "87 days",    "uptime_days": 87,    "uptime_hours": 2094,    "uptime_seconds": 7539660,    "virtual": "vmware"
)