Skip to content

Instantly share code, notes, and snippets.

Created December 4, 2014 01:32
Show Gist options
  • Save anonymous/fcffdca5613636023e1b to your computer and use it in GitHub Desktop.
Save anonymous/fcffdca5613636023e1b to your computer and use it in GitHub Desktop.
def matchArray(line)
match = line.scan(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) #[192.168.220.48]
match.each do |x|
split_array = x.split(".") #192 168 220 48
return string_array = split_array.to_s.rjust(3, '0') #["192", "168", "220", "48"]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment