pub fn regwcomp(reg: &WideStr, flags: RegcompFlags) -> Result<Regex>
Expand description
Compiles a regex that is in the form of a WideStr
.
This is a thin wrapper around Regex::new_wide
.
§Arguments
reg
: regular expression to compile, as aWideStr
.flags
:RegcompFlags
to pass to the function.
§Returns
An opaque Regex
object will be returned.
§Errors
Will return a RegexError
upon failure.
§Examples
use tre_regex::{RegcompFlags, RegexecFlags, regwcomp, regwexec};
use widestring::widestr;
let regcomp_flags = RegcompFlags::new().add(RegcompFlags::EXTENDED);
let regexec_flags = RegexecFlags::new().add(RegexecFlags::NONE);
let compiled_reg = regwcomp(widestr!("[[:digit:]]*"), regcomp_flags)?;
let matches = regwexec(&compiled_reg, widestr!("01234567890"), 1, regexec_flags)?;
for (i, matched) in matches.into_iter().enumerate() {
match matched {
Some(substr) => println!("Match {i}: '{}'", substr.display()),
None => println!("Match {i}: <None>"),
}
}