in reply to Re: Manipulating the Capture(s) of Regular Expressions
in thread Manipulating the Capture(s) of Regular Expressions
sub transform { my ($ref) = @_; $$ref = 'tripped'; } $text = 'The brown cow jumped over the moon'; if ( $text =~ m/cow\s+(jumped)\s+over/ ) { my $ref = \substr($text, $-[1], $+[1] - $-[1]); transform($ref); } print("$text\n"); # The brown cow tripped over the moon
Update: Expanded the example to be runnable.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Manipulating the Capture(s) of Regular Expressions
by missingthepoint (Friar) on Jan 12, 2009 at 06:12 UTC |