RepositoryTypeScriptCHThụy Sĩ
codpro2005

codpro2005/ts-regexp

A RegExp wrapper providing stronger type safety.

327sao
3fork
12issue
0lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: regexp

#1 Repository Của Tháng

1
TINIX TRENDING·Chủ đề: regular-expression

#1 Repository Của Tháng

1
TINIX TRENDING·Chủ đề: type-level

#1 Repository Của Tháng

🧠 ts-regexp: RegExp có type safety thực sự

Wrapper RegExp tự động suy luận kiểu capture groups tại thời điểm biên dịch.

ts-regexp là một thư viện TypeScript nhỏ gọn, cung cấp hàm regex thay thế RegExp với khả năng suy luận kiểu (type inference) chính xác cho cả capture groups thứ tự và tên. Thay vì nhận về { [key: string]: string } như RegExp native, ts-regexp trả về kiểu rõ ràng như { year: string; month: string; day: string }.

✨ Điểm nổi bật

  • Type inference cho capture groups: Tự động suy luận kiểu từ pattern, không cần ép kiểu.
  • Hỗ trợ capture có tên: Các nhóm (?<name>...) được ánh xạ thành object có khóa tương ứng.
  • Phương thức chuẩn: exec, test hoạt động như RegExp nhưng có typing chính xác.
  • Regex-first methods: matchIn, replaceIn, searchIn, splitIn đảo ngược thứ tự tham số để type-safe hơn.
  • Global flag methods: matchAllIn, replaceAllIn chỉ khả dụng khi có flag g.
  • Fallback RegExp: Truy cập pattern.regExp để lấy instance RegExp gốc khi cần.
  • Utility type Parse<T>: Phân tích pattern tại mức type để lấy captures và namedCaptures.

💡 Vì sao đáng chú ý

ts-regexp khác biệt từ RegExp native ở khả năng suy luận kiểu tĩnh thời gian biên dịch, giúp tránh lỗi truy cập sai key hoặc kiểu sai từ capture groups. Phù hợp cho dự án TypeScript cần xử lý regex phức tạp với độ tin cậy cao.


#TypeScript #RegExp #TypeSafety #Regex #OpenSource #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryTypeScript
unjs/magic-regexp

A compiled-away, type-safe, readable RegExp alternative

4.3k
Oct 27, 2026
RepositoryTypeScript
ota-meshi/eslint-plugin-regexp

ESLint plugin for finding regex mistakes and style guide violations.

782
Oct 29, 2026
RepositoryRust
pemistahl/grex

A command-line tool and Rust library with Python bindings for generating regular expressions from user-provided test cases

8.3k
Feb 27, 2026
RepositoryRust
yoav-lavi/melody

Melody is a language that compiles to regular expressions and aims to be more readable and maintainable

4.7k
Nov 24, 2024
RepositoryJavaScript
mathiasbynens/emoji-regex

A regular expression to match all Emoji-only symbols as per the Unicode Standard.

1.9k
Sep 15, 2026
RepositoryGo
dlclark/regexp2

A full-featured regex engine in pure Go based on the .NET engine

1.2k
Oct 28, 2026
RepositoryTypeScript
areknawo/Rex

Your RegEx companion.

289
Jun 15, 2026
RepositoryTypeScript
n8n-io/n8n

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

209.0k
Oct 29, 2026
RepositoryTypeScript
microsoft/vscode

Visual Studio Code

194.4k
Oct 29, 2026