Skip to content

Instantly share code, notes, and snippets.

@dipanjanS
Created April 6, 2019 22:20
Show Gist options
  • Save dipanjanS/e3359625c2f547ef37cd561f5201b93d to your computer and use it in GitHub Desktop.
Save dipanjanS/e3359625c2f547ef37cd561f5201b93d to your computer and use it in GitHub Desktop.
host_pattern = r'(^\S+\.[\S+\.]+\S+)\s'
hosts = [re.search(host_pattern, item).group(1)
if re.search(host_pattern, item)
else 'no match'
for item in sample_logs]
hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment