A Go library that maps regex named groups into struct fields using struct tags and automatic parsing.
Regroup is a Go library that maps named capture groups from regular expressions directly into struct fields using struct tags. It automates the parsing and type conversion of matched text, simplifying the extraction of structured data from strings. This eliminates the need for manual group indexing and repetitive conversion code when working with regex matches.
Go developers who need to parse and extract structured data from text using regular expressions, particularly those working on log processing, data validation, or text analysis tools.
Developers choose Regroup because it provides a declarative, type-safe way to handle regex matches, reducing boilerplate and potential errors. Its automatic parsing of common Go types and support for nested structs makes complex data extraction straightforward and maintainable.
Match regex group into go struct using struct tags and automatic parsing
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically converts matched strings to Go types like int, float, bool, and time.Duration, as shown in examples where Duration and numeric fields are parsed without manual code.
Uses struct tags to map named regex groups to fields, reducing boilerplate and errors, evident in the clean struct definitions with regroup tags.
Handles nested structs and pointers, allowing complex data extraction from a single regex match, demonstrated with struct A containing B in the examples.
Supports required groups and existence checking with bool fields, providing clear error handling for missing or empty groups, as shown in the required and exists tag examples.
Relies on Go's reflection for mapping, which can be slower than direct regex group access and may not suit latency-critical applications.
Requires static struct tags defined at compile time, making it cumbersome or impossible to use with regex patterns generated or modified at runtime.
Only works with named capture groups; if using numbered groups or advanced regex features like lookaheads, manual handling is still required.