XP is just a number | |
PerlMonks |
RFC: Regexp::AllMatchesby lodin (Hermit) |
on Aug 06, 2007 at 16:54 UTC ( [id://630855]=perlmeditation: print w/replies, xml ) | Need Help?? |
The problem Some years ago I wrote a class to find all possible matches of a pattern against a string, including overlapping matches. If there was an /a switch that accomplished this, it would look like this:
I figure I'm going to release it to CPAN. Before I do that I'd appreciate some feedback. Description of the classes I currently call it Regexp::AllMatches and use an OO interface. Here's how it's used:
$matcher is a simple iterator, and the only methods are
$match is a match object that stringifies to the matched string ($&) and implements the following methods:
I also wrote Regexp::AllMatches::Extended that implements some extra convenience methods at the cost of memory and speed.
Regexp::AllMatches and Regexp::AllMatches::Extended will be two different modules. The match object is currently defined in Regexp::AllMatches, and is at the moment not for public instantiation. So, what do you think of
lodin Update: Regexp::Exhaustive is the new name. I'm not too happy about Regexp::Exhaustive::Extended though. Any ideas? How about Regexp::Exhaustive::Extra(s) or Regexp::Exhaustive::Convenient? Update: After a bit of cleaning Regexp::Exhaustive::Extended became nothing but a generic iterator decorator, so it's gone. The all method is now put directly in Regexp::Exhaustive instead. Update: Uploaded to CPAN as Regexp::Exhaustive.
Back to
Meditations
|
|