FLAT::Regex - Regular expressions
A FLAT::Regex object is a regular expression.
In addition to implementing the interface specified in FLAT, FLAT::Regex objects provide the following regex-specific methods:
Returns a regex object representing the expression given in $string. | and + can both be used to denote alternation. * denotes Kleene star, and parentheses can be used for grouping. No other features or shortcut notation is currently supported (character classes, {n,m} repetition, etc).
|
+
*
Whitespaces is ignored. To specify a literal space, use [ ]. This syntax can also be used to specify atomic "characters" longer than a single character. For example, the expression:
[ ]
[foo]abc[bar]*
is treated as a regular expression over the symbols "a", "b", "c", "foo", and "bar". In particular, this means that when the regular expression is reversed, "foo" and "bar" remain the same (i.e, they do not become "oof" and "rab").
The empty regular expression (epsilon) is written as [], and the null regular expression (sometimes called phi) is specified with the # character. To specify a literal hash-character, use [#]. Including literal square bracket characters is currently not supported.
[]
#
[#]
The expression "" (or any string containing only whitespace) is not a valid FLAT regex expression. Either [] or # are probably what was intended.
Returns the string representation of the regex, in the same format as above. It is NOT necessarily true that
FLAT::Regex->new($string)->as_string
is identical to $string, especially if $string contains whitespace or redundant parentheses.
Returns an equivalent Perl regular expression. If the "anchored" option is set to a true value, the regular expression will be anchored with \A and \z. The default behavior is to omit the anchors.
\A
\z
The Perl regex will not contain capturing parentheses. "Extended" characters that are written as "[char]" in FLAT regexes will be written without the square brackets in the corresponding Perl regex. So the following:
FLAT::Regex->new("[foo][bar]*")->as_perl_regex
will be equal to "(?:foo(?:bar)*)".
FLAT is written by Mike Rosulek <mike at mikero dot com> and Brett Estrade <estradb at gmail dot com>.
The initial version (FLAT::Legacy) by Brett Estrade was work towards an MS thesis at the University of Southern Mississippi.
Please visit the Wiki at http://www.0x743.com/flat
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install FLAT, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FLAT
CPAN shell
perl -MCPAN -e shell install FLAT
For more information on module installation, please visit the detailed CPAN module installation guide.