$re = '/(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\/(?:[\d]{1,3})\b(?! is variably)/';
$str = 'D 10.50.80.0/24 [90/3072] via 10.10.10.1, 3w6d, Vlan10
C 10.10.140.0/24 is directly connected, Vlan240
10.10.140.0/2
10.10.140.0/16
2.2.2.2/24
5.5.5.5.5/24
// Negative
10.0.0.0
10.10.60.0/16 is variably subnetted, 58 subnets, 4 masks
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php