
Regex for Hackers (with Python)
Source: YouTube · John Hammond · published Oct 13, 2025 · 39:19
Based on the feedback and the full transcript, here's a revised summary that accurately captures the video's content, structure, and key elements:
Summary:
This tutorial provides a hands-on demonstration of building a Python tool using regular expressions (regex) to automatically redact sensitive information—such as dates, phone numbers, email addresses, credit card numbers, MAC addresses, and IP addresses—from text files. The instructor starts with a practical use case: redacting sensitive data from reports or logs, while subtly introducing regex as a powerful tool for cybersecurity tasks like ethical hacking and penetration testing.
Key Takeaways:
Practical Tool Development
- The tutorial begins by setting up a sample file (
info.md) with fake sensitive data in a Kali Linux environment [0:00-1:40]. - A Python script (
reax_redact.py) is built incrementally to process files, leveraging theremodule and argument parsing for usability [1:40-4:48].
- The tutorial begins by setting up a sample file (
Regex Fundamentals Demonstrated
- Literal vs. Special Characters: Using
.(any character),*(zero or more),+(one or more), and?(optional/non-greedy) to create flexible patterns [4:48-7:20]. - Character Sets: Using
[0-9](digits),[a-z](letters), and\d(shorthand for digits) to match specific data types [10:00-12:30]. - Quantifiers: Applying
{n}(exact count),{min,max}(range), and escaping special characters like\+for phone numbers [12:30-16:00].
- Literal vs. Special Characters: Using
Redaction Patterns for Sensitive Data
- Dates: Pattern matching variations like
YYYY-MM-DDorMM/DD/YYYY, with optional delimiters ([-/]) [16:04-20:10]. - Phone Numbers: Handling formats like
+1 (123) 456-7890using escaped special characters and optional groups [20:11-22:30]. - Credit Cards/MAC Addresses: Using hex character sets (
[a-fA-F0-9]) and chunked patterns (e.g.,XX:XX:XX:XX:XX:XXfor MACs) [22:31-25:08].
- Dates: Pattern matching variations like
Generate CPE Credits
Generate a professional CPE document from this video's transcript.
Estimated credit: 0.5 CPE hours
Estimate uses the video runtime (1 hour ≈ 1 CPE, rounded to the nearest 0.5, minimum 0.5, maximum 2.0). The final amount can be lower after review, never higher.
Topic: Cybersecurity. Commonly maps to: Security and Risk Management, Security Operations. Exact CISSP domains are assigned during generation.
Free account. One generation at a time, with a daily limit.
CPEBuddy is independent and not affiliated with or endorsed by ISC2, ISACA, or any certification body. Exports are formatted for common CPE submissions; acceptance is at your certification body's discretion.
Transcript Preview
First 800 characters of the transcript
Today we'll be doing some work with regular expressions or reax. And if you aren't familiar, reax is an awesome tool for you to be able to track down information across whatever data that you might be looking at. It's pattern matching to find text. You can think of it really simply as like F, but with a heck of a lot more power to find and search and even replace any info you'd like. So I'm on my Kali Linux virtual machine and for us to be able to play with this I'm going to open up a terminal with Ctrl AltT f11 to full screen and I'm going to move into a directory that I have for us called reax redact and I have this super simple file here info.md or info.ext and I can open that up in a text editor. I'll use sublime text and this includes just some sample fake data for us to try and searc…