parse_pattern
Reads a setting that is either a regular expression or a glob: /source/flags is a regular
expression when every flag is valid (d, g, i, m, s, u, v, y), anything else is
a glob. For font substitution rules, ignore lists, filters. Note that /usr/lib/img is the
regular expression usr/lib with the flags img: for paths, build a Pattern::Glob
yourself.
The regular expression is returned as text, since this crate has no regex engine; the source
is not validated. This differs from the TypeScript parsePatternOrRegExp, which compiles the
expression and throws a SyntaxError when it is invalid or repeats a flag (/a/ii): here
both come back as a Pattern::RegExp, and the error appears when you compile it. The flags
are the JavaScript ones; an engine such as the regex crate knows only some of them (i,
m, s, u), so write rules with those to read the same on both sides.
Import
Section titled “Import”Cargo feature string (enabled by default). To compile only this module:
or in Cargo.toml:
Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
pattern | &str | A /source/flags regular expression or a glob. |
Returns
Section titled “Returns”Pattern — The Pattern.
