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
'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html