#group #capture #regex #helper #converting #extracting

regex_captures

Helper for extracting and converting regex capture groups

3 unstable releases

0.2.0 Sep 16, 2023
0.1.1 Sep 15, 2023
0.1.0 Jul 3, 2023

#32 in #extracting

MIT/Apache

8KB
134 lines

Helper for extracting and converting regex capture groups.


lib.rs:

regex_captures makes it easier to work with capture groups when using the regex crate.

Debugging and type conversions using the regex API can be cumbersome, this crate aims to help with this.

All operations are fallible since we do not guarantee that the requested capture groups exist in the supplied regex.

Error-reporting is prioritized over performance. Using this crate when there are a lot expected failures in matching or parsing leads to extra allocations.

Table of methods:

method capture_type conversion total?
get numeric From<str> yes
parse_get numeric FromStr no
try_get numeric TryFrom<str> no
name named From<str> yes
parse_name named FromStr no
try_name named TryFrom<str> no

Examples using all methods:

Dependencies

~2.5–4MB
~72K SLoC