
VerbalExpressions
A JavaScript library that builds regular expressions from readable chained method calls.VerbalExpressions/JSVerbalExpressions
- Stars
- 12.1k
- Forks
- 492
- Licence
- MIT
- Language
- JavaScript
- Last update
- 2.2 years ago
- Type
- Library
No commits in over a year — check for forks or alternatives before adopting.
What it is
VerbalExpressions is a JavaScript library for constructing regular expressions. Instead of writing cryptic regex syntax directly, you chain plain method calls such as startOfLine, then, and maybe to describe the pattern step by step. The README says it is meant to help build difficult regular expressions, and it can be used in the browser or on Node.js.
- Check whether a string is a well-formed URL using a chained pattern
- Find and replace text, such as swapping one word for another
- Build a regex in code and inspect the resulting expression with console.log
Great for
- JavaScript developers who find regex syntax hard to read or write
- Developers who want to document a pattern in a more readable form
- Students learning how regular expressions are built
- Teams maintaining existing VerbalExpressions code
Not ideal for
- Projects that need the smallest possible dependency, since the README does not describe its size or performance cost
- Developers who already write regex fluently and prefer native syntax
- Anyone needing regex features the README does not document, since its coverage is not detailed in the excerpt
How to get it
- 1
Install with a package manager
You'll need: Node.js
Install from npm
npm install verbal-expressions - 2
Run it
- Install the package with npm install verbal-expressions
- Require it with const VerEx = require('verbal-expressions');
- Build a pattern, for example VerEx().find('red').replace('We have a red house', 'blue')
- Run npm test to check the library's tests
- 3
Get the most out of it
- Use console.log on an expression to see the actual regex it produces
- Use the jsDelivr CDN if you want to load it in a browser without a build step
- Review the API documentation at the project's GitHub Pages site for available methods
- Try the JSBin playground linked in the README to experiment before installing
Downloads
Strengths
- Chained method calls make patterns easier to read than raw regex
- Works in the browser via a script tag or CDN, and on Node.js via npm
- Includes a test suite and a documented API site
Trade-offs
- The README is short on details about supported methods beyond the examples
- Last push was 2024-08-07, so maintenance activity may be limited; check the repo before relying on it
- Abstracting regex can hide the exact expression being run unless you log it
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.