Documentation for regex from raw element

Fixes #266.
This commit is contained in:
Laurenz 2023-04-01 19:34:49 +02:00
parent 2d6a79ba32
commit 10a3fbd174

View File

@ -383,6 +383,10 @@ pub fn regex(
/// escape sequences. To produce regex escape sequences that are also valid in
/// Typst (e.g. `[\\]`), you need to escape twice. Thus, to match a verbatim
/// backslash, you would need to write `{regex("\\\\")}`.
///
/// If you need many escape sequences, you can also create a raw element
/// and extract its text to use it for your regular expressions:
/// ```{regex(`\d+\.\d+\.\d+`.text)}```.
regex: Spanned<EcoString>,
) -> Value {
Regex::new(&regex.v).at(regex.span)?.into()