Regular expressions are a way for programs to search through text and find patterns, like checking whether a string is a valid email address or an IP address. The problem is that regular expressions are written in a compact notation that looks like line noise to most people, even experienced developers. Readex is a small JavaScript library that lets you write those same patterns using named functions instead of symbols, making the intent of each piece much easier to read. Instead of writing a cryptic string of characters, you compose your pattern by calling functions like zeroOrMore, digit, startOfLine, or captureGroup. These functions can be nested and combined freely, and they all return standard JavaScript RegExp objects that work exactly like patterns you would write by hand. There is no new engine or special runtime involved, just a more readable way to express what you already could. The library ships functions for all the main building blocks of a regular expression: character sets, quantifiers that control how many times something should repeat, grouping to collect matched text, lookahead and lookbehind assertions that check what comes before or after a match without consuming it, and backreferences to refer back to text you already matched. The API is available as an npm package and works in any modern JavaScript environment. A practical example from the README shows building an IPv4 address matcher. The octet pattern for a number between 0 and 255 is built from reusable pieces, then combined four times with dots between them. The resulting code reads almost like a description of the problem rather than an encoding trick. If you find yourself writing regular expressions often and struggling to remember what each symbol does, this library offers a more approachable way to get the same results.
← chalarangelo on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.