As explained on https://crates.io/crates/regex-lite, `regex-lite` is a lighter alternative to `regex` and seems to be sufficient for our purposes.
23 lines
741 B
Rust
23 lines
741 B
Rust
#![allow(clippy::expect_used)]
|
|
|
|
use regex_lite::Regex;
|
|
|
|
// This is defined in its own file so we can limit the scope of
|
|
// `allow(clippy::expect_used)` because we cannot scope it to the `lazy_static!`
|
|
// macro.
|
|
lazy_static::lazy_static! {
|
|
/// Regular expression that matches Codex-style source file citations such as:
|
|
///
|
|
/// ```text
|
|
/// 【F:src/main.rs†L10-L20】
|
|
/// ```
|
|
///
|
|
/// Capture groups:
|
|
/// 1. file path (anything except the dagger `†` symbol)
|
|
/// 2. start line number (digits)
|
|
/// 3. optional end line (digits or `?`)
|
|
pub(crate) static ref CITATION_REGEX: Regex = Regex::new(
|
|
r"【F:([^†]+)†L(\d+)(?:-L(\d+|\?))?】"
|
|
).expect("failed to compile citation regex");
|
|
}
|