NAME

Regexp - Object Oriented interface to perl's regular expression code

SYNOPSIS

    use Regexp;

    my $re = new Regexp q/Some Pattern/;

    if (match $re "Some String") { ... }

    $re->prematch

    $re->postmatch

    $re->pattern

    my @info  = $re->backref
    my $count = $re->backref

DESCRIPTION

CONSTRUCTORS

new ( PATTERN [, FLAGS ] )

new compiles the given PATTERN into a new Regexp object. See perlre for a description of PATTERN

A second optional parameter, FLAGS, can be used to control how the pattern is compiled. FLAGS is a numeric value which can be constructed by or-ing together constants which Regexp conditionally exports. The constants are :

FOLD

Perform case-insensitive matches. See /i in perlre

NOCASE

A synonym for FOLD

MULTILINE

Treat strings as multiple lines, See /m in perlre

SINGLELINE

Treat strings as single lines, See /s in perlre

EXTENDED

Use extended patter formats to increase legibility, See /x in perlre

current

Returns an object which represents the current (last) pattern.

METHODS

minlength

Returns the minimum length that a string has to be before it will match the regular expression

pattern

Returns the pattern text

match ( STRING [, OFFSET [, FLAGS]] )

match is like the =~ operator in perl. STRING is the string which the regexp is to be applied. OFFEST and FLAGS are both optional.

In a scalar context match returns a true or false value depending on whether the match was sucessful. In an array context match returns an array of the contents of all the backreferences, or an empty array.

OFFSET, if given, directs the regexp code to start trying to match the regexp at the given offset from the start of STRING

FLAGS is a numeric value which can be constructed by or-ing together constants which Regexp conditionally exports. The constants are :

GLOBAL

Match as many times as possible, starting each time where the previous match ended. See /g option in perlre.

If match is called in an array context and the GLOBAL flag is set then the result will be an array of all the backreferences from all the matches.

nparens

Returns the number of parentheses in the expression

lastparen

Returns the number of the last parentheses that matched.

backref ( [INDEX] )

The result of backref is sensetive to how it is called.

If called with a single argument then backref returns the text for the given backreference in the pattern. Backreferences are numbered from 1 as with $1..$9.

If called with a single argument of zero, then backref will return the text of the last match. (Same as lastmatch)

If called without any arguments, and in a scalar context, then backref will return the number of backreferences that there are in the Regexp object. (Same as nparens)

If called without any arguments, and in aN array context, then backref will return a list of all the backreference values from the last match.

prematch

Returns the text preceeding the text of the last match

lastmatch

Returns the text of the last match

postmatch

Returns the text following the text of the last match

startpos

Returns the offset into the original string to the start of the text in the last match.

length

Returns the length of the text in the last match

endpos

Returns the offset into the original string to the end of the text in the last match.

AUTHORS

Regexp is a combination of work by Nick Ing-Simmons <nick@ni-s.u-net.com> and Ilya Zakharevich <ilya@math.ohio-state.edu> brought together and improved by Graham Barr <bodg@tiuk.ti.com>