Day 15 of 100 Days Coding Challenge: Python
Regex: the ancient incantation whispered into the void to extract meaning from chaosโor at least, thatโs how it feels when you’re debugging it. At work, Iโve been diving into Power Automate, and with a little AI sidekick magic, I managed to whip up a subroutine. Hereโs the catch: management is monitoring AI usage as if it were a high-budget Netflix subscription. So if I want to justify it, I have to show resultsโpreferably in PDF form or extracted text using OCR. Thatโs where regex comes in, acting like a digital highlighter that says, โHey, this is the bit I want.โ
Sure, there are online regex testers, but handing my data to a mystery site on the internet? Not ideal. So, why not just build my own? And voilร โRegex Tester was born, with all the drama of pattern matching and none of the corporate paranoia.
Todayโs Motivation / Challenge
Todayโs goal was all about building something practical and safe. When you’re automating document workflows at workโespecially with sensitive PDFs or scanned imagesโyou want something you can trust. This project enables me to test patterns locally without sharing data, providing me with full control and peace of mind. Additionally, it’s oddly satisfying to watch regex do its detective work in real-time.
Purpose of the Code (Object)
This simple GUI-based tool lets you test regular expressions against any input text. You type in a pattern, paste some text, and instantly see what matchesโalong with where they appear. Itโs a private sandbox for your regex experiments, with none of the โOops, I just uploaded company secrets to a sketchy websiteโ anxiety.
AI Prompt:
Write a Python program using Tkinter that creates a GUI for testing regular expressions. The user should be able to input a regex pattern and a test string. When a button is pressed, the program should display all matching strings and their positions. Display errors if the pattern is invalid. Keep the interface clean, responsive, and beginner-friendly.
Functions & Features
- Input fields for both regex pattern and test string
- โTest Regexโ button to trigger evaluation
- Results window showing matches and positions
- Error handling for invalid patterns
- All offlineโno data ever leaves your machine
Requirements / Setup
bash
CopyEdit
Python 3.x (Tkinter is included in standard library)
No need to install anythingโjust run the .py file.
Minimal Code Sample
import re
compiled = re.compile(pattern)
matches = compiled.finditer(test_string)
This finds all the places your pattern matches the test stringโlike a digital bloodhound sniffing out structure.
Notes / Lessons Learned
I tested it with some of the Frankenstein-like regex I use at workโand it worked like a charm. Finally, no more awkward toggling between browsers and paranoia over leaking sensitive data. And best of all? It feels good to have built something so useful with my own keyboard and caffeine. Regex might still be cryptic sorcery, but now at least itโs my sorcery.
Optional Ideas for Expansion
- Add a checkbox for case-insensitive search
- Highlight matches directly in the test text field
- Save and reload common patterns from a local file

