Skip to main content

Crate brace_expansion

Crate brace_expansion 

Source
Expand description

§brace-expansion — bash-style brace expansion

Expand brace patterns the way bash does: a{b,c}d becomes ["abd", "acd"], {1..3} becomes ["1", "2", "3"], with nested sets, numeric and alphabetic sequences (with an optional step and zero-padding), and backslash escaping. A faithful Rust port of the brace-expansion npm package (the expander behind minimatch/glob). Zero dependencies and #![no_std].

use brace_expansion::expand;

assert_eq!(expand("a{b,c}d"), ["abd", "acd"]);
assert_eq!(expand("{1..3}"), ["1", "2", "3"]);
assert_eq!(expand("{a..c}"), ["a", "b", "c"]);
assert_eq!(expand("{01..03}"), ["01", "02", "03"]);
assert_eq!(expand("a{b,c{d,e}}f"), ["abf", "acdf", "acef"]);

Constants§

EXPANSION_MAX
The default cap on the number of generated results, matching the npm package.

Functions§

expand
Expand a brace pattern, returning every resulting string in order.
expand_with_max
Expand a brace pattern, capping the number of results at max.