moonbitstack/moonregex/prop does not have a README file

    CharSet

    pub struct CharSet {
    ranges : Array[(Int, Int)]
    } derive(Eq)

    A set of code points, kept as sorted disjoint inclusive ranges.

    Character classes, \p{...}, \w and the rest are all this one shape, so the set algebra a pattern needs — union for [a-z], difference for --, intersection for &&, complement for [^…] — lives here once.
    impl Debug for CharSet

    CharSet::any

    fn CharSet::any() -> CharSet

    Every code point, surrogates included.

    CharSet::complement

    fn CharSet::complement(self : CharSet) -> CharSet

    Complement over every code point: what [^…] means.

    CharSet::contains

    fn CharSet::contains(self : CharSet, c : Int) -> Bool

    Whether a code point is in the set.

    CharSet::difference

    fn CharSet::difference(self : CharSet, other : CharSet) -> CharSet

    Difference: the V1 set algebra's --.

    CharSet::empty

    fn CharSet::empty() -> CharSet

    The empty set.

    CharSet::equal

    fn CharSet::equal(CharSet, CharSet) -> Bool

    CharSet::fold

    fn CharSet::fold(self : CharSet) -> CharSet

    Close the set under simple case folding: add the folded form of everything in it, and the unfolded form of everything that folds into it.

    This is what (?i) does to a class at parse time: fold the pattern, not the input, so the executor stays a plain membership test. Only single code point folds exist here, so ß does not grow an ss — matching it against SS is out of scope, exactly as it is in Python's re.

    CharSet::intersection

    fn CharSet::intersection(self : CharSet, other : CharSet) -> CharSet

    Intersection: the V1 set algebra's &&.

    CharSet::is_empty

    fn CharSet::is_empty(self : CharSet) -> Bool

    Whether the set holds nothing.

    CharSet::not_equal

    fn CharSet::not_equal(x : CharSet, y : CharSet) -> Bool

    CharSet::of

    fn CharSet::of(ranges : Array[(Int, Int)]) -> CharSet

    Build a set from ranges, sorting and merging them first.

    The input may be in any order and may overlap; the stored form is always sorted, disjoint and coalesced, which is what makes contains a binary search and the algebra linear.

    CharSet::ranges

    fn CharSet::ranges(self : CharSet) -> Array[(Int, Int)]

    The stored ranges, sorted and disjoint.

    CharSet::single

    fn CharSet::single(c : Int) -> CharSet

    A set holding exactly one code point.

    CharSet::symmetric_difference

    fn CharSet::symmetric_difference(self : CharSet, other : CharSet) -> CharSet

    Symmetric difference: the V1 set algebra's ~~.

    CharSet::to_repr

    CharSet::union

    fn CharSet::union(self : CharSet, other : CharSet) -> CharSet

    Union: [a-z] or, in the V1 set algebra, ||.

    ascii_digit

    let ascii_digit : CharSet

    ascii_space

    let ascii_space : CharSet

    ascii_word

    let ascii_word : CharSet

    The same three, restricted to ASCII, which is what the A flag and the ECMA-262 dialect without u mean by them.

    binary

    fn binary(name : StringView) -> CharSet?

    A binary property: Alphabetic, White_Space, Emoji.

    block

    fn block(name : StringView) -> CharSet?

    A block: Basic Latin, BasicLatin, CJK Unified Ideographs.

    A block is one range, so the usual answer needs no walk at all; the walk is only for spellings the UCD's reader does not take.

    category

    fn category(name : StringView) -> CharSet?

    A general category: L, Lu, Uppercase_Letter, casedletter.

    char_of_name

    fn char_of_name(name : StringView) -> Int?

    The code point a Unicode character name denotes — what \N{name} answers from. Names are read loosely, the way unicodedata.lookup reads them.

    digit

    fn digit() -> CharSet

    \d: decimal digits, and only those.

    fold

    fn fold(c : Char) -> Char

    The simple fold of a code point; a code point with no fold is its own.

    fold_pairs

    fn fold_pairs() -> Array[(Int, Int)]

    The fold pairs, sorted by source — what a class is closed under.

    property

    fn property(name : StringView) -> CharSet?

    Any property, however it is spelled — the shape \p{...} takes.

    name=value is accepted too: Script=Latin, General_Category=Lu, Block=CJK Unified Ideographs. The left side picks the table, the right side the entry; without it, every table is searched in the order a Unicode name would be looked up: category, script, block, binary property.

    script

    fn script(name : StringView) -> CharSet?

    A script: Latin, Latn, Han.

    The short code and the long name are one name to the UCD, so the name is resolved through the UCD's own reader first and only then looked up.

    space

    fn space() -> CharSet

    \s: the White_Space property.

    version

    fn version() -> String

    Which Unicode the answers follow.

    word

    fn word() -> CharSet

    \w under the Python and mrab spellings: letters, numbers and the underscore. Python's own words for it are "alphanumeric (as str.isalnum has it) plus _", which is exactly these categories.

    Source Files

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io