A Go library for constructing regular expressions using a human-friendly, composable builder pattern.
Rex is a Go library that provides a builder pattern for constructing regular expressions. It aims to improve code readability, maintainability, and reusability by offering a structured, composable API over raw regex syntax, and it integrates seamlessly with Go's standard regexp package, returning standard *regexp.Regexp objects.
Go developers who need to write, maintain, or understand complex regular expressions in their codebases, particularly those prioritizing clarity and reusability over concise raw regex strings.
Developers choose Rex because it replaces cryptic regex symbols with a human-friendly, method-chained API that supports composable blocks, predefined helpers for common patterns, and the ability to embed raw regex for flexibility, all while producing standard Go regexp objects.
Flexible regular expressions constructor for Golang.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses method chains like rex.Chars.Lower().Repeat().OneOrMore() to replace cryptic symbols, making regex patterns easier to understand and maintain, as highlighted in the README examples.
Supports groups, character classes, and repetitions that can be combined and parameterized, enabling the creation of custom helpers for dynamic regex construction, as documented in the library features.
Allows embedding raw regular expressions anywhere with rex.Common.Raw() or RawVerbose(), facilitating a hybrid approach for incremental refactoring or leveraging existing patterns.
Includes utilities for patterns like number ranges, emails, and phones, reducing the need to write complex regex from scratch, as noted in the key features section.
Deliberately writes more code than raw regex, which can increase codebase size and feel cumbersome for simple patterns, a criticism the FAQ acknowledges with 'It is too verbose.'
Limited to Go projects; while generated regex strings can be copied, the builder API isn't transferable, adding vendor lock-in for teams working in multi-language environments.
Adds a building layer that may introduce slight performance overhead during regex compilation compared to directly using raw strings, though matching performance is unchanged.