Is there an equivalent for "index" that uses regular expressions instead of exact string?


I've been looking at index, pos, m//, and the corresponding "$" variables but nothing I've found so far does what I'm looking for. Specifically, what I'm trying to do is find all the starting locations of a RE match. For example, using an exact string match:

$ perl -e '$foo="baaaab"; $re="aa" ;
for ($bar=index($foo, $re); $bar >= 0 ; $bar=index($foo, $re, $bar+1))
{ print $bar, "\t" }
print "\n" ; '
1 2 3


I'd like to do the same except use a regular expression. BTW, notice that matches can overlap.

Any thoughts or ideas?

Regards,
- Robert
http://www.cwelug.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to