The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Data::Object::Regexp - A Regexp Object for Perl 5

VERSION

version 0.16

SYNOPSIS

    use Data::Object::Regexp;

    my $re = Data::Object::Regexp->new(qr(something to match against));

DESCRIPTION

Data::Object::Regexp provides common methods for operating on Perl 5 regular expressions. Data::Object::Regexp methods work on data that meets the criteria for being a regular expression.

COMPOSITION

This class inherits all functionality from the Data::Object::Role::Regexp role and implements proxy methods as documented herewith.

METHODS

    # given qr((test))

    $re->search('this is a test');
    $re->search('this does not match', 'gi');

The search method performs a regular expression match against the given string This method will always return a Data::Object::Regexp::Result object which can be used to introspect the result of the operation.

replace

    # given qr(test)

    $re->replace('this is a test', 'drill');
    $re->replace('test 1 test 2 test 3', 'drill', 'gi');

The replace method performs a regular expression substitution on the given string. The first argument is the string to match against. The second argument is the replacement string. The optional third argument might be a string representing flags to append to the s///x operator, such as 'g' or 'e'. This method will always return a Data::Object::Regexp::Result object which can be used to introspect the result of the operation.

SEE ALSO

AUTHOR

Al Newkirk <anewkirk@ana.io>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by Al Newkirk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.