Regexp::Util - A selection of general-utility regexp subroutines
use Regexp::Util qw( :all ); my $stringified = serialize_regexp( qr/^foo/ ); my $regexp = deserialize_regexp( $stringified ); "foobar" =~ $regexp;
This module provides the following functions:
is_regexp($ref)
Returns a boolean indicating whether $ref is a regexp reference. Is not tricked by blessed regexps.
$ref
regexp_seen_evals($re)
Returns true if $re contains embedded Perl code.
$re
regexp_is_foreign($re)
Returns true if $re uses a regexp engine plugin.
(Since Perl 5.10, it has been possible to use regexp engine plugins, such as re::engine::PCRE and re::engine::RE2.)
serialize_regexp($re)
Serializes the regexp to a string of Perl code.
Croaks if the regexp contains embedded Perl code, or uses a regexp engine plugin.
deserialize_regexp($str)
Evaluates a string of Perl code generated by serialize_regexp to return the original regexp object. Uses Safe, and also checks that the return value is a regexp, so should be somewhat safer than eval($str).
serialize_regexp
eval($str)
This module can also re-export regexp_pattern($re), regmust($re), regname($name, $all), regnames($all), and regnames_count() from re for convenience.
regexp_pattern($re)
regmust($re)
regname($name, $all)
regnames($all)
regnames_count()
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Regexp-Util.
More regexp stuff: re.
Other util modules: Scalar::Util, List::Util, Hash::Util.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2014, 2018 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
To install Regexp::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Regexp::Util
CPAN shell
perl -MCPAN -e shell install Regexp::Util
For more information on module installation, please visit the detailed CPAN module installation guide.