in reply to Is there a regular expression version of the index function?
If you are already using regexes, @- is all you need. But if you are just looking for a drop-in replacement for index, well, I have used this:
sub regindex { my ($str, $rx, $pos) = @_; pos($str) = $pos || 0; $str =~ /$rx/g or return -1; return $-[0]; }
print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a regular expression version of the index function?
by rzward (Monk) on Jun 20, 2004 at 13:13 UTC | |
by rzward (Monk) on Jun 21, 2004 at 10:21 UTC |