Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

Extract URI Using Perl Regexp::Common

I wanted to see the urls to several things and didn’t want any other text cluttering my notes. Perl to the rescue, specifically Regexp::Common.

There are several ways to get a URI, and Regexp::Common will get 99% of the URIs. It works for what I needed, and took 10 seconds to implement - so, here it is:

#!/usr/bin/perl

use warnings;
use strict;

use Regexp::Common qw/URI/;

while(<data>) {
	my $str = $_;
	my ($uri) = $str =~ /$RE{URI}{-keep}/;
	print $uri . "\n";

}

__DATA__
  <div><a href="https://www.icollege.co/course/cissp-certified-information-systems-security-professional-2015-new">CISSP : Certified Information Systems Security Professional 2015</a></div>
  <div><a href="https://www.icollege.co/course/comptia-security-sy0-401-new">CompTIA Security + SY0-401</a></div>
  <div><a href="https://www.icollege.co/course/comptia-advanced-security-practitioner-casp-new">CompTIA  Advanced Security Practitioner (CASP)</a></div>
  <div><a href="https://www.icollege.co/course/comptia-advanced-security-practitioner-casp">CompTIA Advanced Security Practitioner (CASP)</a></div>
  <div><a href="https://www.icollege.co/course/cisco-210-065-implementing-cisco-video-network-devices-civnd1-civnd2">Cisco 210-065: Implementing Cisco Video Network Devices (CIVND1 & CIVND2)</a></div>
  <div><a href="https://www.icollege.co/course/cissp-certified-information-systems-security-professional-2015">CISSP: Certified Information Systems Security Professional 2015 </a></div>
  <div><a href="https://www.icollege.co/course/cisco-210-060-implementing-cisco-collaboration-devices-ccid">Cisco 210-060: Implementing Cisco Collaboration Devices (CCID)</a></div>
  <div><a href="https://www.icollege.co/course/cisco-200-355-implementing-cisco-wireless-networking-fundamentals">Cisco 200-355: Implementing Cisco Wireless Networking Fundamentals</a></div>
  <div><a href="https://www.icollege.co/course/cisco-200-105-interconnecting-cisco-networking-devices-part-2-icnd2-v3">Cisco 200-105 Interconnecting Cisco Networking Devices Part 2 - ICND2 v3</a></div>
  <div><a href="https://www.icollege.co/course/cisco-300-115-switch-implementing-cisco-ip-switched-networks-new">Cisco 300 -115 - SWITCH - Implementing Cisco IP Switched Networks</a></div>
  <div><a href="https://www.icollege.co/course/cisco-300-135-tshoot-troubleshooting-and-maintaining-cisco-ip-networks">Cisco 300-135 - TSHOOT - Troubleshooting And Maintaining Cisco IP Networks</a></div>
  <div><a href="https://www.icollege.co/course/csa-certificate-cloud-technology-security-knowledge-ccsk">CSA Certificate of Cloud Technology Security Knowledge (CCSK)</a></div>
  <div><a href="https://www.icollege.co/course/certified-information-systems-auditor-cisa">Certified Information Systems Auditor (CISA)</a></div>
  <div><a href="https://www.icollege.co/course/certified-information-security-manager-cism">Certified Information Security Manager (CISM)</a></div>
  <div><a href="https://www.icollege.co/course/risk-management-professional-pmi-rmp">Risk Management Professional (PMI-RMP) </a></div>
  <div><a href="https://www.icollege.co/course/cisco-300-101-route-implementing-cisco-ip-routing-new">Cisco 300 -101 - ROUTE - Implementing Cisco IP Routing</a></div>
  <div><a href="https://www.icollege.co/course/cisco-210-260-implementing-cisco-network-security">Cisco 210-260: Implementing Cisco Network Security</a></div>
  <div><a href="https://www.icollege.co/course/com-hacking-forensic-invest-chfi">Computer Hacking Forensic Investigator (CHFI)</a></div>
  <div><a href="https://www.icollege.co/course/cisco-100-105-interconnecting-cisco-networking-devices-part-1-icnd1-v3">Cisco 100-105: Interconnecting Cisco Networking Devices Part 1 - ICND1 v3</a></div>
  <div><a href="https://www.icollege.co/course/comptia-cysa-cyber-security-analyst">CompTIA CySA+  (Cyber Security Analyst)</a></div>
  <div><a href="https://www.icollege.co/course/comptia-security-sy0-501">CompTIA Security+ SY0-501</a></div>
Last updated on 3 Jan 2019
Published on 3 Jan 2019