1.1.0 • Published 5 months ago
@savagechieftain/regext v1.1.0
RegExt - Extended Regular Expression Class
- RegExt is a TypeScript library that provides convenient utility methods by extending JavaScript's standard RegExp class.
- It offers complete TypeScript support and type safety.
Features
- 🚀 Full TypeScript support
- 📦 ES Modules & CommonJS support
- 🔧 Rich extension methods
- 🛡️ Type-safe operations
- 📝 Comprehensive JSDoc documentation
Installation
npm install regextUsage
ES Modules (TypeScript/JavaScript)
import RegExt from 'regext';
// Full type support in TypeScript
const regex = new RegExt('\\d+', 'g');
const numbers: string[] = regex.extract('abc123def456');
console.log(numbers); // ['123', '456']CommonJS
const RegExt = require('regext').default;TypeScript
import RegExt from 'regext';Quick Start
import RegExt from 'regext';
const regex = new RegExt('\\d+', 'g');
// Extract all numbers from text
const numbers = regex.extract('Price: $29.99, Tax: $3.50');
console.log(numbers); // ['29', '99', '3', '50']
// Count matches
const count = regex.count('123 456 789');
console.log(count); // 3
// Safe testing without affecting lastIndex
const hasNumbers = regex.safeTest('abc123');
console.log(hasNumbers); // trueMethods Overview
loopExec(str)- Get all matches with infinite loop preventionsafeTest(str)- Test without modifying lastIndexextract(str)- Extract matched strings as arrayextractGroups(str)- Extract capture groupsreplaceAll(str, replacement)- Replace all matchesreplaceFirst(str, replacement)- Replace first match onlycount(str)- Count number of matchesfindLast(str)- Get the last match
Documentation
- 📖 API Reference - Complete API documentation
- 💡 Usage Examples - Practical examples and use cases
- 🤝 Contributing - Development setup and guidelines
License
MIT