Package Exports
- regex-friendly
Readme
regex-friendly
Readable, chainable, and type-safe regex helpers for JavaScript & TypeScript.
Stop fighting unreadable regex — write them friendly instead.
✨ Features
- ✅ Chainable transformations (
.noSpace().onlyNumbers()...
) - ✅ Static methods for quick one-offs
- ✅ Validations (
isEmail
,isUUID
,isPhoneNumber
, etc.) - ✅ Functions (
formatCardNumber
,validateCreditCard
) - ✅ String transformations (remove spaces, keep only numbers, reverse, custom regex)
- ✅ 30+ built-in common & advanced regex patterns
- ✅ Fully typed with IntelliSense auto-completion
- ✅ Works in Node.js and modern browsers
📦 Installation
npm install regex-friendly
# or
yarn add regex-friendly
# or
pnpm add regex-friendly
🚀 Usage
Static methods
import RegexFriendly from "regex-friendly";
import { transformations, validations } from "regex-friendly";
RegexFriendly.onlyNumbers("a1b2c3");
// "123"
transformations.removeNumbers("abc123xyz");
// "abcxyz"
RegexFriendly.isEmail("test@example.com");
// true
validations.isUrl("https://example.com");
// true
Chainable methods
RegexFriendly("Hello World 123").noSpace().onlyNumbers().result();
// "123"
Custom transformation
RegexFriendly.custom("foo bar", /foo/g, "baz");
// "baz bar"
Or in a chain:
RegexFriendly("foo bar baz")
.custom(/foo/, "hello")
.custom(/baz/, "world")
.result();
// "hello bar world"
🧩 Available Helpers
🔹 Transformations
noSpace()
onlyNumbers()
onlyLetters()
reverseString()
custom(regex, replacement)
- …and more
🔹 Validations
isEmail()
isPhoneNumber()
isUUID()
isHexColor()
isIPAddress()
- …and 20+ others
📜 License
MIT © Emmanuel Eze