Skip to content

Instantly share code, notes, and snippets.

@googya
Last active March 5, 2018 05:28
Show Gist options
  • Save googya/eb6594f2a9f1e0981f1a54e5aeda5556 to your computer and use it in GitHub Desktop.
Save googya/eb6594f2a9f1e0981f1a54e5aeda5556 to your computer and use it in GitHub Desktop.
reg_obj = Regexp.new('([a-z]*\.?){1,3}\.ishanggang\.com')
s = `ag "#{reg_obj.to_s}"`
lines = s.split(/\t|\n/)
res = lines.each_with_object([]) do |e, arr|
if e =~ reg_obj
arr << $~.to_s
end
end.uniq.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment