NAME

Regex::Iterator - provides an iterator interface to regexps

SYNOPSIS

my $it = Regex::Iterator->new($regex, $string);

while (my $match = $it->match) {
	$it->replace('replaced') if $match eq 'replaceable';
}
print $it->result,"\n";

DESCRIPTION

Inspired by Mark Jason Dominus' talk Programming with Iterators and Generators (available from http://perl.plover.com/yak/iterators/) this is an iterative regex matcher based on the work I did for URI::Find::Iterator

METHODS

new <regex> <string>

Fairly self explanatory - takes a regex and a string to match it against.

regex can be the result of a qr{}

match

Returns the current match as a string.

It then advances to the next one.

replace <replacement>

Replaces the current match with replacement

result

Returns the string with all replacements.

BUGS

None that I know of but there are probably loads.

COPYING

Distributed under the same terms as Perl itself.

AUTHOR

Copyright (c) 2003, Simon Wistow <simon@thegestalt.org>

SEE ALSO

URI::Find::Iterator, http://perl.plover.com/yak/iterators/