Urgent.News

What's breaking now, across thousands of outlets.

Tech

Every regex is written once and read a hundred times. Optimize for the readers.

Somewhere in a codebase you own there's a regex that three people can write and nobody can read. Mine was a date-validation pattern — forty-some characters of punctuation and backreference syntax that I wrote in one sitting and then spent an hour decoding six months later when the edge case arrived. The edge case, of course, was one the regex never handled, because I had no reliable way to see…

In a codebase, there often exists a regular expression (regex) that only three individuals can comprehend, yet it remains unreadable by all. One such example was a date-validation pattern, consisting of forty characters of punctuation and backreference syntax. Initially crafted in a single session, it later took an hour to decode when an edge case surfaced, which the regex had not anticipated due to the lack of a reliable method to observe its actual behavior versus the author's assumptions.

Every regex is written once and read approximately a hundred times, making it crucial to optimize for readability rather than solely focusing on the writer. By explaining the regex part by part and highlighting potential edge cases, these complex patterns become more accessible to the entire team. The differences in regex engines, such as JavaScript, PCRE, and Java, are not merely cosmetic – they can lead to critical bugs in production environments.

To address this issue, a tool called RegexProof is introduced. It takes a plain-English description of the desired regex functionality and generates a working regex pattern in the specified language's syntax. Furthermore, it provides a detailed explanation of the regex, including the edge cases that need to be considered. This process not only helps in creating a more understandable regex but also in catching potential bugs before they impact users.

However, it's essential to note that RegexProof is not a replacement for thorough testing. While it can generate a regex pattern based on a description, it still requires rigorous testing, particularly focusing on the edge cases explicitly mentioned. Performance optimization is also not addressed by RegexProof, as it is the user's responsibility to ensure the regex pattern is efficient and resistant to catastrophic backtracking issues on malicious input.

Finally, the tool relies solely on the accuracy of the provided description, so it is crucial to be as specific as possible when defining the desired regex behavior.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

My Journey as a First-Year Computer Science Student

**Starting out in computer science feels exciting but also kind of overwhelming at the same time. I am just getting into how computers work and what programming really involves.

  • Foundational concepts like algorithms and logical sequences are prioritized over complex issues.
  • Collaboration and time management are crucial skills for managing tasks and working with others.

GitView CodeAudit: Go security reviews that never leave your laptop

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle What I Built GitView CodeAudit is a security review for Go backends that runs on your laptop.

  • GitView CodeAudit conducts Go backend security reviews on local laptops
  • Provides offline HTML report with evidence and reviewer decisions
  • Free tool for freelancers and small agencies to generate security reports

Two Agencies Wrote "Top Agencies" Lists — One Put Itself at #1

A reader question sent us down a rabbit hole worth sharing: when agencies write their own "top agencies in the UK" listicles — which, as we found earlier this week , is how the UK's list layer works…

  • Munro Agency claims #1 spot in its Top 12 Content Marketing Agencies list
  • Koozai lists itself at entry #8 in its Best Content Marketing Agencies in the UK list
  • Koozai's list includes criteria for evaluating agencies before naming them

Project Gleipnir

Gleipnir: confining AI coding agents on a home Linux workstation A home-lab writeup by Patrick Robinson. Industrial electrician and automation tech moving into OT/ICS network security; CompTIA…

  • Project Gleipnir uses AI agents on a home Linux workstation for studying and building.
  • Each AI agent operates as its own Linux user with sandboxed launch and controlled network egress.
  • Recovery steps documented separately to prevent unintended rollbacks during main runbook execution.

More from Sunday 18 October →