Skip to main content

Crate use_regex

Crate use_regex 

Source
Expand description

§use-regex

Practical regex helper utilities for RustUse.

Warning: versions below 0.3.0 are experimental and may change as the workspace matures.

§Example Usage

use use_regex::{escape_regex, is_valid_regex};

assert_eq!(escape_regex("a+b"), "a\\+b");
assert!(is_valid_regex(r"\d+"));

§Scope

  • lightweight wrappers around the mature regex crate
  • simple validation, matching, extraction, and replacement helpers
  • string-oriented utilities that stay small and predictable

§Non-Goals

  • regex engine implementation
  • parser generators
  • validation frameworks
  • security sandboxing

§License

Licensed under either of the following, at your option:

  • MIT License
  • Apache License, Version 2.0

Structs§

RegexCapture
A captured value and its byte span.
RegexFlags
Optional flags that can be applied when constructing a regex.
RegexPattern
A reusable owned regex pattern wrapper.

Functions§

count_regex_matches
Counts matches for a valid pattern.
escape_regex
Escapes regex metacharacters in a literal string.
extract_regex_captures
Extracts capture groups across all matches for a valid pattern.
extract_regex_matches
Extracts matched substrings for a valid pattern.
has_regex_match
Returns true when the pattern matches any part of the input.
is_valid_regex
Returns true when the pattern compiles successfully.
looks_like_regex
Returns true when the input appears to contain regex syntax.
regex_ends_with
Returns true when a valid pattern matches at the end of the input.
regex_starts_with
Returns true when a valid pattern matches at the beginning of the input.
replace_regex_all
Replaces all matches for a valid pattern.