CS615A -- Aspects of System Administration - Regex Exercise

Text Processing

Write a quick tool that reads input from stdin and then extracts exactly and only the following:

  • valid date strings; examples include 03/07/2016, 7.3.2016, 2016-03-07, 2016/03/07
  • valid IPv4 addresses; examples include 0.0.0.0, 255.255.255.255, 127.0.0.1, 155.246.089.001
  • valid IPv6 addresses; examples include ::1, fe80::e276:63ff:fe72:3900%xennet0, 2001:470:30:84:e276:63ff:fe72:3900, 0:0:0:0:0:ffff:66.163.162.9
  • URLs; examples include http://example.com, ftp://example.com/dir/file.html, https://example.com/?foo=bar&blob=';alert(1);, http://example.com/?redir=http://example.com
  • individual words; examples include word, it's, Name, Henry the 3rd, cross-site scripting

Before writing the actual code, make sure to first phrase the input set in words. This will help you define and understand the problem.


[Course Website]