Parse::RandGen::CharClass - Character class (i.e. [a-f0-9]) terminal Condition element.


CharClass is a terminal Condition element that models a character class (e.g. [0-9a-fA-f], [^-\n\r], [AaBbCcDd], etc...).

Internally, the character class is broken down into a 256 character long string and an offset. The offset is the first character that is outside of the character set. All characters before the offset are inside the set and all characters at or after the offset are outside the set.

The characters before and after the offset are in character ordinal order. This ensures that separate CharClass objects that have equivalent character classes will use the same 256 byte string (so Perl will ref count the same memory, instead of duplicating it).



Creates a new CharClass. The first argument (required) is the character class element (e.g. qr/[a-z0-9]/). The character class element consists of a compiled regular expression that matches only one character. All other arguments are named pairs.

The CharClass class supports the optional arguments "min" and "max", which represent the number of times that the subrule must match for the condition to match.

The "quant" quantifier argument can also be used to specify "min" and "max". The values are the familiar '+', '?', or '*' (also can be 's', '?', or 's?', respectively).

element, min, max

Returns the CharClass's attribute of the same name.


Parse::RandGen::Condition, Parse::RandGen::Regexp, and Parse::RandGen


Jeff Dutton