{"id":29363081,"url":"https://github.com/duongnguyen321/rgex","last_synced_at":"2025-07-10T11:02:52.682Z","repository":{"id":302796405,"uuid":"1013597786","full_name":"duongnguyen321/rgex","owner":"duongnguyen321","description":"A powerful, chainable regex builder platform with comprehensive validation utilities","archived":false,"fork":false,"pushed_at":"2025-07-04T08:47:44.000Z","size":51,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-04T09:43:38.316Z","etag":null,"topics":["builder-pattern","chainable","email-validation","password-validation","pattern-matching","regex","regular-expressions","text-to-code","typescript","typescript-library","url-validation","validation"],"latest_commit_sha":null,"homepage":"https://npmjs.com/rgex","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duongnguyen321.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-04T06:51:56.000Z","updated_at":"2025-07-04T08:47:47.000Z","dependencies_parsed_at":"2025-07-04T09:43:41.340Z","dependency_job_id":"a65583b3-8d61-4f75-9082-d3971794f1b4","html_url":"https://github.com/duongnguyen321/rgex","commit_stats":null,"previous_names":["duongnguyen321/rgex"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/duongnguyen321/rgex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duongnguyen321%2Frgex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duongnguyen321%2Frgex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duongnguyen321%2Frgex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duongnguyen321%2Frgex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duongnguyen321","download_url":"https://codeload.github.com/duongnguyen321/rgex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duongnguyen321%2Frgex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264390125,"owners_count":23600516,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["builder-pattern","chainable","email-validation","password-validation","pattern-matching","regex","regular-expressions","text-to-code","typescript","typescript-library","url-validation","validation"],"created_at":"2025-07-09T09:42:38.203Z","updated_at":"2025-07-10T11:02:52.670Z","avatar_url":"https://github.com/duongnguyen321.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RGex: The Intelligent Regex Toolkit\n\n[![NPM Version](https://img.shields.io/npm/v/rgex?style=flat-square\u0026color=CB3837\u0026logo=npm)](https://www.npmjs.com/package/rgex)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue?style=flat-square\u0026logo=typescript)](https://www.typescriptlang.org/)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/duongnguyen321/rgex/ci.yml?branch=main\u0026style=flat-square)](https://github.com/duongnguyen321/rgex/actions/workflows/ci.yml)\n[![License](https://img.shields.io/npm/l/rgex?style=flat-square\u0026color=lightgrey)](./LICENSE)\n\n**RGex is a powerful, modern, and chainable regular expression builder for TypeScript and JavaScript.** It transforms cryptic regex syntax into a readable, fluent API. With features like human-text-to-regex parsing, advanced validation utilities, and a rich set of pre-built patterns, RGex simplifies even the most complex pattern-matching tasks.\n\n## ✨ Key Features\n\n- **🔗 Fluent \u0026 Chainable API**: Construct complex regex patterns with an intuitive, readable builder.\n- **🧠 Human Text Intelligence**: Convert natural language descriptions into regex patterns (`t2r`) or validation rules (`t2v`). The intelligent parser understands simple keywords (\"email\"), complex sequences (\"starts with letters, then numbers\"), and logical conditions (\"jwt or uuid\").\n- **🛡️ Advanced Validation**: A comprehensive suite of over 45 validation tools for passwords, emails, and dozens of modern data formats, including JWTs, cryptocurrency addresses, cloud resource identifiers, and international standards (IBAN, SemVer).\n- **📚 Rich Pattern Library**: Includes over 50 ready-to-use constants and builder methods for common types like `EMAIL`, `URL`, `DATE`, and advanced patterns for `JWT`, `SEMVER`, `MONGO_ID`, `BITCOIN_ADDRESS`, `DOCKER_IMAGE`, and more.\n- **🚀 TypeScript Native**: Built with TypeScript for full type safety, autocompletion, and a great developer experience.\n- **📦 Zero Dependencies**: Lightweight and self-contained.\n\n## 📦 Installation\n\n```bash\nnpm install rgex\n```\n\n## 🚀 Core Concepts\n\nRGex is built on three main pillars that you can use independently or together.\n\n### 1. The `RGex` Fluent Builder\n\nThe `RGex` class is a chainable API for constructing patterns method-by-method. It's best for when you need full, granular control.\n\n```typescript\nimport { RGex } from 'rgex';\n\nconst usernameRegex = RGex.create()\n\t.start()\n\t.charClass('a-zA-Z0-9_-') // Letters, numbers, underscore, hyphen\n\t.quantifier(3, 16) // 3 to 16 characters long\n\t.end()\n\t.build(); // -\u003e /^[a-zA-Z0-9_-]{3,16}$/\n```\n\n### 2. Human Text to Regex (`t2r`)\n\nFor rapid development, `t2r` converts a description into a ready-to-use regex. It's powered by a sophisticated parser that understands a wide variety of patterns.\n\n```typescript\nimport { t2r } from 'rgex';\n\n// Generates a complex pattern with lookaheads for each requirement\nconst { pattern } = t2r(\n\t'password with 2 uppercase 2 lowercase 2 numbers 2 special chars'\n);\n```\n\n_Aliases: `h2r`, `humanToRegex`, `textToRegex`, `parseHumanTextToRegex`_\n\n### 3. Human Text to Validation (`t2v`)\n\nSimilarly, `t2v` creates a set of validation rules from a description. It's perfect for validating forms and data without writing regex.\n\n```typescript\nimport { t2v } from 'rgex';\n\n// Simple validation\nconst emailValidation = t2v('required email');\n\n// Advanced validation using the rich pattern library\nconst apiTokenValidation = t2v(\n\t'valid jwt token or git commit hash',\n\t'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.t-IDcSemACt8xhtWd80xX1cdO43a-G_jp49CV-inFpQ'\n);\n\nconsole.log(apiTokenValidation.allPassed); // true\n```\n\n_Aliases: `h2v`, `humanToValidation`, `textToValidation`, `parseHumanTextToValidation`_\n\n---\n\n## 📖 Full API Reference\n\nThe library exports a rich set of classes, functions, types, and constants.\n\n### The `RGex` Class API\n\nThis is the core of the fluent builder pattern.\n\n#### Static Methods\n\n| Method                                  | Description                                                 |\n| --------------------------------------- | ----------------------------------------------------------- |\n| `RGex.create(pattern?, opts?)`          | Creates a new `RGex` instance.                              |\n| `RGex.toRegex(text)` (`h2r`)            | Converts human text to a regex pattern.                     |\n| `RGex.toValidate(text)` (`h2v`)         | Converts human text to validation rules.                    |\n| `RGex.getSuggestions(text)` (`suggest`) | Gets pattern suggestions for a text string.                 |\n| `RGex.humanText(text)`                  | Creates a `RGex` instance directly from a text description. |\n| `RGex.fromJSON(json)`                   | Creates an instance from a JSON object.                     |\n| `RGex.escape(text)`                     | Escapes special regex characters in a string.               |\n| `RGex.validate(pattern)`                | Validates if a string is a valid regex pattern.             |\n| `RGex.normalize(text)`                  | Normalizes text (e.g., removes diacritics).                 |\n\n#### Builder \u0026 Pattern Methods\n\n| Method                                        | Description                                     |\n| --------------------------------------------- | ----------------------------------------------- |\n| `.literal(text)`                              | Adds literal text, escaping special characters. |\n| `.raw(pattern)`                               | Adds a raw, unescaped regex pattern.            |\n| `.charClass(chars, negate?)`                  | Creates a character class like `[a-z0-9]`.      |\n| `.digit()`, `.word()`, `.whitespace()`        | Adds `\\d`, `\\w`, or `\\s`.                       |\n| `.group(pattern)`                             | Creates a capturing group `(...)`.              |\n| `.quantifier(min, max?)`                      | Specifies quantity, e.g., `{1,3}`.              |\n| `.or(pattern)`                                | Adds an \"or\" condition (`\\|`).                  |\n| `.start()`, `.end()`                          | Anchors the pattern with `^` and `$`.           |\n| `.lookahead(p, neg?)`, `.lookbehind(p, neg?)` | Adds lookarounds.                               |\n| `.email()`, `.url()`, `.uuid()`, etc.         | Appends pre-built patterns for common types.    |\n\n#### Flag \u0026 Execution Methods\n\n| Method                               | Description                                                         |\n| ------------------------------------ | ------------------------------------------------------------------- |\n| `.ignoreCase()` / `.global()` / etc. | Sets regex flags (`i`, `g`, etc.).                                  |\n| `.build()`                           | Builds and returns the final `RegExp` object.                       |\n| `.test(input)`                       | Tests the pattern against a string.                                 |\n| `.exec(input)`                       | Executes the pattern and returns match details.                     |\n| `.clone()`                           | Creates a copy of the `RGex` instance.                              |\n| `.reset()`                           | Clears the pattern and options.                                     |\n| `.toString()`                        | Returns the string representation `/pattern/flags`.                 |\n| `.toJSON()`                          | Returns a JSON representation of the pattern and flags.             |\n| `.passwordCase(options?)`            | Performs detailed password strength analysis on the pattern string. |\n\n### Standalone Functions\n\nThese can be imported and used directly without a `RGex` instance.\n\n#### Password \u0026 Validation Utilities\n\n| Function                        | Description                                                    |\n| ------------------------------- | -------------------------------------------------------------- |\n| `validatePassword(pass, opts?)` | Performs a comprehensive password strength analysis.           |\n| `generateStrongPassword(opts?)` | Generates a cryptographically secure password.                 |\n| `getPasswordSuggestions(pass)`  | Suggests improvements for a weak password.                     |\n| `hasCommonWords(pass)`          | Checks if a password is in a list of common passwords.         |\n| `hasSequentialChars(pass)`      | Checks for sequential characters (e.g., \"abc\", \"123\").         |\n| `hasRepeatingChars(pass)`       | Checks for repeating character sequences (e.g., \"aaa\", \"111\"). |\n| `isValidEmail(email)`           | Validates an email address.                                    |\n| `isValidRegex(pattern)`         | Validates if a string is a valid regex pattern.                |\n\n#### General \u0026 Helper Utilities\n\n| Function                        | Description                                                             |\n| ------------------------------- | ----------------------------------------------------------------------- |\n| `escapeRegex(text)`             | Escapes special regex characters.                                       |\n| `extractNumbers(text)`          | Extracts all numbers from a string.                                     |\n| `normalizeText(text)`           | Removes diacritics and normalizes whitespace.                           |\n| `mergePatterns(...patterns)`    | Combines multiple regex patterns into one.                              |\n| `generateTestData(pattern)`     | Generates random test data that matches a regex.                        |\n| `calculatePatternComplexity(p)` | Calculates a complexity score for a regex pattern.                      |\n| `optionsToFlags(opts)`          | Converts a `RegexBuilderOptions` object to a flags string (e.g., \"gi\"). |\n| `flagsToOptions(flags)`         | Converts a flags string to an options object.                           |\n\n### Exported Constants\n\nUse these constants to access pre-built patterns and character sets directly.\n\n- **`REGEX_PATTERNS`**: An object containing over 50 ready-to-use regex patterns, including `EMAIL`, `URL`, `UUID`, `JWT`, `IPV4`, `SEMVER`, `CREDIT_CARD`, `MONGO_ID`, `BITCOIN_ADDRESS`, `DOCKER_IMAGE`, and more.\n- **`HUMAN_PATTERNS`**: Maps human-readable phrases to their corresponding regex patterns.\n- **`VALIDATION_PATTERNS`**: A collection of over 45 validation rule factories for common data types.\n- **`PATTERN_KEYWORDS`**: Keywords used by `t2r` to identify pattern types.\n- **`VALIDATION_KEYWORDS`**: A dictionary of over 100 keywords and aliases used by `t2v` to identify validation rules (e.g., 'ssn', 'social security', 'jwt').\n- **`COMMON_PASSWORDS`**: A `Set` containing thousands of common passwords.\n- **`SPECIAL_CHARS`**, **`SYMBOLS`**: Strings containing sets of special characters for password generation and validation.\n\n### Exported Types\n\nRGex is fully typed for a superior developer experience.\n\n- **`RGex`**: The core class.\n- **`RegexBuilderOptions`**: Options for the builder (e.g., `{ global: true }`).\n- **`TextExtractionResult`**: The return type of `t2r`, containing the pattern, confidence, etc.\n- **`ValidationExtractionResult`**: The return type of `t2v`, containing rules and pass/fail status.\n- **`PasswordValidationOptions`**: Rules for password validation (e.g., `{ minLength: 8, hasUpper: true }`).\n- **`PasswordValidationResult`**: The detailed analysis object returned by `validatePassword`.\n- **`ValidationRule`**: A type representing a single validation rule.\n- **`HumanTextPattern`**: The structure for defining human-to-regex mappings.\n\n### Configuration\n\n- **`RGEX_CONFIG`**: A global configuration object containing default settings, feature flags, and messages used by the library.\n\n## 📚 Official Documentation\n\nFor a deep dive into every function, type, and constant, please see our **[Full API Documentation](https://duongnguyen321.github.io/rgex)**, which is automatically generated from the source code via [TypeDoc](https://typedoc.org/) and includes the **[Advanced T2R/T2V Patterns Guide](./T2R-T2V.md)**.\n\n## 🤝 Contributing\n\nContributions are welcome! Whether it's a bug report, a new feature, or an improvement to the documentation, please feel free to open an issue or submit a pull request.\n\n## 📜 License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](./LICENSE) file for details.\n\n\u003e A project by [@duonguyen.site AKA codetails.site](https://codetails.site)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduongnguyen321%2Frgex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduongnguyen321%2Frgex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduongnguyen321%2Frgex/lists"}